summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Evans <jasone@FreeBSD.org>2000-08-23 08:11:13 +0000
committerJason Evans <jasone@FreeBSD.org>2000-08-23 08:11:13 +0000
commit60719a69b2a9bae8eab341f1da5a002300e3d960 (patch)
treef6b036c79742070e263a91f8e21a48c84fe5d75a
parent85541729bf3a25b4db82be98b249b714f7f63ea4 (diff)
Notes
-rw-r--r--lib/libc_r/man/sem_post.33
-rw-r--r--lib/libc_r/uthread/uthread_sem.c7
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/libc_r/man/sem_post.3 b/lib/libc_r/man/sem_post.3
index 906d86d87c2b..34fef83c614d 100644
--- a/lib/libc_r/man/sem_post.3
+++ b/lib/libc_r/man/sem_post.3
@@ -48,6 +48,9 @@ If there are threads blocked on the semaphore when
is called, then the highest priority thread that has been blocked the longest on
the semaphore will be allowed to return from
.Fn sem_wait .
+.Pp
+.Fn sem_post
+is signal-reentrant and may be called within signal handlers.
.Sh RETURN VALUES
If successful,
.Fn sem_post
diff --git a/lib/libc_r/uthread/uthread_sem.c b/lib/libc_r/uthread/uthread_sem.c
index 10dec5ed036f..2dcf72223fc3 100644
--- a/lib/libc_r/uthread/uthread_sem.c
+++ b/lib/libc_r/uthread/uthread_sem.c
@@ -206,6 +206,12 @@ sem_post(sem_t *sem)
_SEM_CHECK_VALIDITY(sem);
+ /*
+ * sem_post() is required to be safe to call from within signal
+ * handlers. Thus, we must defer signals.
+ */
+ _thread_kern_sig_defer();
+
pthread_mutex_lock(&(*sem)->lock);
(*sem)->count++;
@@ -221,6 +227,7 @@ sem_post(sem_t *sem)
pthread_mutex_unlock(&(*sem)->lock);
+ _thread_kern_sig_undefer();
retval = 0;
RETURN:
return retval;