From 4b14b206dba06c39b1fe2be941edba5fb34cc6f3 Mon Sep 17 00:00:00 2001 From: Jukka Laitinen Date: Wed, 2 Apr 2025 14:37:12 +0300 Subject: [PATCH] sched: Replace direct semaphore value access with nxsem_get_value Signed-off-by: Jukka Laitinen --- sched/signal/sig_default.c | 6 +++++- sched/task/task_exithook.c | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sched/signal/sig_default.c b/sched/signal/sig_default.c index a2c01438570..f70e01e2eef 100644 --- a/sched/signal/sig_default.c +++ b/sched/signal/sig_default.c @@ -303,6 +303,8 @@ static void nxsig_stop_task(int signo) if ((group->tg_waitflags & WUNTRACED) != 0) { + int semvalue; + /* Return zero for exit status (we are not exiting, however) */ if (group->tg_statloc != NULL) @@ -319,11 +321,13 @@ static void nxsig_stop_task(int signo) /* Wakeup any tasks waiting for this task to exit or stop. */ - while (group->tg_exitsem.semcount < 0) + nxsem_get_value(&group->tg_exitsem, &semvalue); + while (semvalue < 0) { /* Wake up the thread */ nxsem_post(&group->tg_exitsem); + nxsem_get_value(&group->tg_exitsem, &semvalue); } } #endif diff --git a/sched/task/task_exithook.c b/sched/task/task_exithook.c index 9b72d34fe01..268931b247d 100644 --- a/sched/task/task_exithook.c +++ b/sched/task/task_exithook.c @@ -315,6 +315,7 @@ static inline void nxtask_signalparent(FAR struct tcb_s *ctcb, int status) static inline void nxtask_exitwakeup(FAR struct tcb_s *tcb, int status) { FAR struct task_group_s *group = tcb->group; + int semvalue; /* Have we already left the group? */ @@ -360,11 +361,13 @@ static inline void nxtask_exitwakeup(FAR struct tcb_s *tcb, int status) group->tg_statloc = NULL; group->tg_waitflags = 0; - while (group->tg_exitsem.semcount < 0) + nxsem_get_value(&group->tg_exitsem, &semvalue); + while (semvalue < 0) { /* Wake up the thread */ nxsem_post(&group->tg_exitsem); + nxsem_get_value(&group->tg_exitsem, &semvalue); } } }