Commit 6b8a2b8fcd99c4365b1aa9513c0f0149beac2491

Martin Pieuchot 2020-01-19T13:46:59

Remove unnecessary pthread_yield(3). In the two cases a context switch isn't necessary as the thread isn't blocked and doesn't need to wait for its sibling.

diff --git a/tog/tog.c b/tog/tog.c
index ac26de5..0e878ef 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -747,15 +747,6 @@ view_input(struct tog_view **new, struct tog_view **dead,
 	*focus = NULL;
 
 	if (view->searching && !view->search_next_done) {
-		errcode = pthread_mutex_unlock(&tog_mutex);
-		if (errcode)
-			return got_error_set_errno(errcode,
-			    "pthread_mutex_unlock");
-		pthread_yield();
-		errcode = pthread_mutex_lock(&tog_mutex);
-		if (errcode)
-			return got_error_set_errno(errcode,
-			    "pthread_mutex_lock");
 		view->search_next(view);
 		return NULL;
 	}
@@ -1638,16 +1629,6 @@ trigger_log_thread(int load_all, int *commits_needed, int *log_complete,
 		if (errcode)
 			return got_error_set_errno(errcode,
 			    "pthread_cond_signal");
-		errcode = pthread_mutex_unlock(&tog_mutex);
-		if (errcode)
-			return got_error_set_errno(errcode,
-			    "pthread_mutex_unlock");
-		pthread_yield();
-		errcode = pthread_mutex_lock(&tog_mutex);
-		if (errcode)
-			return got_error_set_errno(errcode,
-			    "pthread_mutex_lock");
-
 		if (*commits_needed > 0 && (!load_all || --max_wait <= 0)) {
 			/*
 			 * Thread is not done yet; lose a key press