diff options
author | 1999-05-26 00:17:41 +0000 | |
---|---|---|
committer | 1999-05-26 00:17:41 +0000 | |
commit | c81e763c7bc3f7c3ec8b05460237e5c67b9ae1bf (patch) | |
tree | 74e5975e7eb70c69b9e0711599c328a23d8ed698 /lib/libpthread/uthread/uthread_detach.c | |
parent | document two new states (deadlock and spinblock) (diff) | |
download | wireguard-openbsd-c81e763c7bc3f7c3ec8b05460237e5c67b9ae1bf.tar.xz wireguard-openbsd-c81e763c7bc3f7c3ec8b05460237e5c67b9ae1bf.zip |
sync with FreeBSD
Diffstat (limited to 'lib/libpthread/uthread/uthread_detach.c')
-rw-r--r-- | lib/libpthread/uthread/uthread_detach.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/libpthread/uthread/uthread_detach.c b/lib/libpthread/uthread/uthread_detach.c index d4fa639fef8..cb51ff0e43d 100644 --- a/lib/libpthread/uthread/uthread_detach.c +++ b/lib/libpthread/uthread/uthread_detach.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: uthread_detach.c,v 1.3 1999/01/06 05:29:23 d Exp $ + * $OpenBSD: uthread_detach.c,v 1.4 1999/05/26 00:18:23 d Exp $ */ #include <errno.h> #ifdef _THREAD_SAFE @@ -52,11 +52,24 @@ pthread_detach(pthread_t pthread) /* Flag the thread as detached: */ pthread->attr.flags |= PTHREAD_DETACHED; + /* + * Guard against preemption by a scheduling signal. + * A change of thread state modifies the waiting + * and priority queues. + */ + _thread_kern_sched_defer(); + /* Enter a loop to bring all threads off the join queue: */ while ((next_thread = _thread_queue_deq(&pthread->join_queue)) != NULL) { /* Make the thread run: */ PTHREAD_NEW_STATE(next_thread,PS_RUNNING); } + + /* + * Reenable preemption and yield if a scheduling signal + * occurred while in the critical region. + */ + _thread_kern_sched_undefer(); } else /* Return an error: */ rval = EINVAL; |