hartmannathan opened a new issue #587: pthread_mutex_lock() does not resume 
waiting after signal
URL: https://github.com/apache/incubator-nuttx/issues/587
 
 
   According to the description of `pthread_mutex_lock()` (in the function's 
comment block):
   
   "If a signal is delivered to a thread waiting for a mutex, upon return from 
the signal handler the thread resumes waiting for the mutex as if it was not 
interrupted."
   
   But the code does not appear to do this.
   
   `pthread_mutex_lock()` is a thin wrapper around `pthread_mutex_timedlock()` 
with a NULL abs_timeout. `pthread_mutex_timedlock()` calls 
`pthread_mutex_take()` with a intr value of true, which in turn calls 
`pthread_sem_take()` with intr value of true, which calls `nxsem_wait()`. 
`nxsem_wait()` returns -EINTR if awakened by a signal.
   
   In the above mentioned callers, there does not appear to be logic to detect 
this case and resume waiting for the mutex as if it was not interrupted per the 
specification.
   
   Notes:
   
   (1) While the comment block above `pthread_mutex_timedlock()` does not make 
a similar statement as `pthread_mutex_lock()` regarding interruption by a 
signal, OpenGroup.org seems to 
[suggest](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_timedlock.html)
 that it should: "The pthread_mutex_timedlock() function shall lock the mutex 
object referenced by mutex. If the mutex is already locked, the calling thread 
shall block until the mutex becomes available as in the pthread_mutex_lock() 
function."
   
   (2) See the dev@ mailing list thread entitled "pthread_mutex_lock() and 
signals" started 13 Mar 2020, archived here: 
[https://lists.apache.org/thread.html/rc366bf8ab1291e3f4d36ef90a2a2b4dc25d4f89db7ffc57df320e7ce%40%3Cdev.nuttx.apache.org%3E](https://lists.apache.org/thread.html/rc366bf8ab1291e3f4d36ef90a2a2b4dc25d4f89db7ffc57df320e7ce%40%3Cdev.nuttx.apache.org%3E)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to