Make sem_post() safe to call from within a signal handler, as required by
POSIX/SUSv2.
This commit is contained in:
parent
c467495440
commit
1ff9faf229
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user