summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libc/gen/sem_post.33
-rw-r--r--lib/libc_r/man/sem_post.33
-rw-r--r--lib/libc_r/uthread/uthread_sem.c7
-rw-r--r--lib/libkse/thread/thr_sem.c7
-rw-r--r--lib/libpthread/man/sem_post.33
-rw-r--r--lib/libpthread/thread/thr_sem.c7
6 files changed, 30 insertions, 0 deletions
diff --git a/lib/libc/gen/sem_post.3 b/lib/libc/gen/sem_post.3
index 906d86d..34fef83 100644
--- a/lib/libc/gen/sem_post.3
+++ b/lib/libc/gen/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/man/sem_post.3 b/lib/libc_r/man/sem_post.3
index 906d86d..34fef83 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 10dec5e..5a4757c 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_defer();
retval = 0;
RETURN:
return retval;
diff --git a/lib/libkse/thread/thr_sem.c b/lib/libkse/thread/thr_sem.c
index 10dec5e..5a4757c 100644
--- a/lib/libkse/thread/thr_sem.c
+++ b/lib/libkse/thread/thr_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_defer();
retval = 0;
RETURN:
return retval;
diff --git a/lib/libpthread/man/sem_post.3 b/lib/libpthread/man/sem_post.3
index 906d86d..34fef83 100644
--- a/lib/libpthread/man/sem_post.3
+++ b/lib/libpthread/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/libpthread/thread/thr_sem.c b/lib/libpthread/thread/thr_sem.c
index 10dec5e..5a4757c 100644
--- a/lib/libpthread/thread/thr_sem.c
+++ b/lib/libpthread/thread/thr_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_defer();
retval = 0;
RETURN:
return retval;
OpenPOWER on IntegriCloud