diff options
Diffstat (limited to 'lib/libkse/thread/thr_kill.c')
-rw-r--r-- | lib/libkse/thread/thr_kill.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/libkse/thread/thr_kill.c b/lib/libkse/thread/thr_kill.c index 7572c05..c729179 100644 --- a/lib/libkse/thread/thr_kill.c +++ b/lib/libkse/thread/thr_kill.c @@ -52,6 +52,13 @@ pthread_kill(pthread_t pthread, int sig) /* Find the thread in the list of active threads: */ else if ((ret = _find_thread(pthread)) == 0) { + /* + * Guard against preemption by a scheduling signal. + * A change of thread state modifies the waiting + * and priority queues. + */ + _thread_kern_sched_defer(); + switch (pthread->state) { case PS_SIGSUSPEND: /* @@ -108,6 +115,12 @@ pthread_kill(pthread_t pthread, int sig) sigaddset(&pthread->sigpend,sig); break; } + + /* + * Reenable preemption and yield if a scheduling signal + * occurred while in the critical region. + */ + _thread_kern_sched_undefer(); } /* Return the completion status: */ |