From 228266df1122dd0b3102d45629ae1e0d7ae42f31 Mon Sep 17 00:00:00 2001 From: deischen Date: Wed, 15 Mar 2000 13:59:27 +0000 Subject: Fix pthread_suspend_np/pthread_resume_np. For the record, suspending a thread waiting on an event (I/O, condvar, etc) will, when resumed using pthread_resume_np, return with EINTR. For example, suspending and resuming a thread blocked on read() will not requeue the thread for the read, but will return -1 with errno = EINTR. If the suspended thread is in a critical region, the thread is suspended as soon as it leaves the critical region. Fix a bogon in pthread_kill() where a signal was being delivered twice to threads waiting in sigwait(). Reported by (suspend/resume bug): jdp Reviewed by: jasone --- lib/libc_r/uthread/uthread_cancel.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/libc_r/uthread/uthread_cancel.c') diff --git a/lib/libc_r/uthread/uthread_cancel.c b/lib/libc_r/uthread/uthread_cancel.c index f22bfb5..82ddbb8 100644 --- a/lib/libc_r/uthread/uthread_cancel.c +++ b/lib/libc_r/uthread/uthread_cancel.c @@ -37,6 +37,15 @@ pthread_cancel(pthread_t pthread) pthread->cancelflags |= PTHREAD_CANCELLING; break; + case PS_SUSPENDED: + /* + * This thread isn't in any scheduling + * queues; just change it's state: + */ + pthread->cancelflags |= PTHREAD_CANCELLING; + PTHREAD_SET_STATE(pthread, PS_RUNNING); + break; + case PS_SPINBLOCK: case PS_FDR_WAIT: case PS_FDW_WAIT: @@ -52,7 +61,6 @@ pthread_cancel(pthread_t pthread) case PS_WAIT_WAIT: case PS_SIGSUSPEND: case PS_SIGWAIT: - case PS_SUSPENDED: /* Interrupt and resume: */ pthread->interrupted = 1; pthread->cancelflags |= PTHREAD_CANCELLING; -- cgit v1.1