From: Giuseppe Scrivano Date: Thu, 14 Jan 2010 09:32:44 +0000 (+0100) Subject: the thread_yield return value considers blocked threads too X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e4f249057d3de1a3b86629f66949333a06a796cd;p=emacs.git the thread_yield return value considers blocked threads too --- diff --git a/src/thread.c b/src/thread.c index f19cb4fc43d..eae83afa3c0 100644 --- a/src/thread.c +++ b/src/thread.c @@ -37,7 +37,14 @@ static pthread_t next_thread; static void thread_schedule () { - next_thread = NEXT_THREAD (current_thread)->pthread_id; + struct thread_state *it = current_thread; + do + { + it = NEXT_THREAD (it); + } + while (it->blocked && it != current_thread); + + next_thread = it->pthread_id; } /* Schedule a new thread and block the caller until it is not scheduled @@ -387,13 +394,7 @@ thread_select (n, rfd, wfd, xfd, tmo) int other_threads_p (void) { - int avail = 0; - struct thread_state *it = all_threads; - for (; it && avail < 2; it = it->next_thread) - if (!it->blocked) - avail++; - - return avail > 1; + return all_threads->next ? 1 : 0; } Lisp_Object