casaroli commented on code in PR #20815:
URL: https://github.com/apache/nuttx/pull/20815#discussion_r4345656714
##########
libs/libc/semaphore/sem_wait.c:
##########
@@ -37,6 +37,21 @@
#include <nuttx/atomic.h>
#include <nuttx/irq.h>
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* In the kernel, a pending signal must not make the wait fail at once (see
+ * nxsem_wait_slow()). User space gets the signal when the call returns.
+ */
+
+#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
Review Comment:
In user space the flag would also stop a signal from ending `sem_wait()` of
the application with `EINTR`. There the retry does not spin: the signal is
delivered when the system call returns.
##########
sched/semaphore/sem_wait.c:
##########
@@ -97,13 +97,13 @@ int nxsem_wait_slow(FAR sem_t *sem)
* sem_wait_irq(). If sem_wait then blocks without re-checking unmasked
* pending signals, it can sleep indefinitely and miss the interrupt.
*
- * Not for a mutex: a mutex wait is not interrupted by a signal, and the
- * kernel retries it until it gets the mutex (mm_lock(), for example).
- * During a system call an unmasked signal stays pending until the call
- * returns, so the check would make every retry fail at once.
+ * Not for a mutex or an uninterruptible semaphore: the kernel retries
+ * them until it gets the semaphore (mm_lock(), for example). During a
+ * system call an unmasked signal stays pending until the call returns,
+ * so the check would make every retry fail at once.
*/
- if (!mutex)
+ if (!mutex && (sem->flags & SEM_TYPE_UNINTERRUPTIBLE) == 0)
Review Comment:
Never: other tasks can wait on the same semaphore at that time, and a clear
would make their retries spin again.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]