xiaoxiang781216 commented on code in PR #20815:
URL: https://github.com/apache/nuttx/pull/20815#discussion_r4345316314
##########
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:
when we clear this flag
##########
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:
why need `#if`
##########
sched/semaphore/sem_tickwait.c:
##########
@@ -153,6 +153,10 @@ int nxsem_tickwait_uninterruptible(FAR sem_t *sem,
uint32_t delay)
clock_t end = clock_delay2abstick(delay);
int ret;
+ /* A pending signal must not make the wait fail at once */
+
+ sem->flags |= SEM_TYPE_UNINTERRUPTIBLE;
Review Comment:
nxsem_set_uninterruptible
--
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]