diff options
| author | John Birrell <jb@FreeBSD.org> | 1999-03-23 05:07:56 +0000 |
|---|---|---|
| committer | John Birrell <jb@FreeBSD.org> | 1999-03-23 05:07:56 +0000 |
| commit | 58a7cc5d1be640708d2c5e05bf48a8ae379a8d3e (patch) | |
| tree | eea0761f32968ad5456e1c13f86e990df50fa554 /lib/libpthread/thread/thr_detach.c | |
| parent | f5a78334492dccb1f3e9debe40f6e1deb14638fd (diff) | |
Notes
Diffstat (limited to 'lib/libpthread/thread/thr_detach.c')
| -rw-r--r-- | lib/libpthread/thread/thr_detach.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/libpthread/thread/thr_detach.c b/lib/libpthread/thread/thr_detach.c index da456bfbab90..05da832e0c07 100644 --- a/lib/libpthread/thread/thr_detach.c +++ b/lib/libpthread/thread/thr_detach.c @@ -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; |
