libc_r/uthread/uthread_join.c

Marc Olzheim marcolz at stack.nl
Wed Dec 31 03:16:45 PST 2003


Hi.

Is there a reason why in the case that a thread is not done yet,
pthread_join() does not call _thread_kern_sig_undefer() ?

We have a program where one thread consumes all CPU it can get for
blocks of data.
A status thread is spawned as soon as the main thread starts working on
a new block, printing an 'x % done' message and sleeping for a second in
a loop. When the block is processed, the status thread is
pthread_cancel()d and the main thread does a pthread_join() to wait for
the status thread to exit. Now, when the second block is to be
processed, a new status thread is spawned, but since signals are still
defered and the main thread needs all the cpu it can get, it doesn't get
scheduled in anymore.

The following fixed the problem in 4-STABLE and it seems to work ok, but
I'm no sure if there was a reason for the omission of the call in that
case...


--- uthread_join.c	Tue Oct 22 16:44:03 2002
+++ uthread_join.c.fixed	Wed Dec 31 12:12:33 2003
@@ -136,6 +136,9 @@
 		ret = curthread->join_status.error;
 		if ((ret == 0) && (thread_return != NULL))
 			*thread_return = curthread->join_status.ret;
+
+		/* Undefer and handle pending signals, yielding if necessary: */
+		_thread_kern_sig_undefer();
 	} else {
 		/*
 		 * The thread exited (is dead) without being detached, and no

Zlo


More information about the freebsd-hackers mailing list