Skip to content

Commit 4b14b20

Browse files
jlaitinexiaoxiang781216
authored andcommitted
sched: Replace direct semaphore value access with nxsem_get_value
Signed-off-by: Jukka Laitinen <[email protected]>
1 parent cd84da8 commit 4b14b20

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Diff for: sched/signal/sig_default.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ static void nxsig_stop_task(int signo)
303303

304304
if ((group->tg_waitflags & WUNTRACED) != 0)
305305
{
306+
int semvalue;
307+
306308
/* Return zero for exit status (we are not exiting, however) */
307309

308310
if (group->tg_statloc != NULL)
@@ -319,11 +321,13 @@ static void nxsig_stop_task(int signo)
319321

320322
/* Wakeup any tasks waiting for this task to exit or stop. */
321323

322-
while (group->tg_exitsem.semcount < 0)
324+
nxsem_get_value(&group->tg_exitsem, &semvalue);
325+
while (semvalue < 0)
323326
{
324327
/* Wake up the thread */
325328

326329
nxsem_post(&group->tg_exitsem);
330+
nxsem_get_value(&group->tg_exitsem, &semvalue);
327331
}
328332
}
329333
#endif

Diff for: sched/task/task_exithook.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ static inline void nxtask_signalparent(FAR struct tcb_s *ctcb, int status)
315315
static inline void nxtask_exitwakeup(FAR struct tcb_s *tcb, int status)
316316
{
317317
FAR struct task_group_s *group = tcb->group;
318+
int semvalue;
318319

319320
/* Have we already left the group? */
320321

@@ -360,11 +361,13 @@ static inline void nxtask_exitwakeup(FAR struct tcb_s *tcb, int status)
360361
group->tg_statloc = NULL;
361362
group->tg_waitflags = 0;
362363

363-
while (group->tg_exitsem.semcount < 0)
364+
nxsem_get_value(&group->tg_exitsem, &semvalue);
365+
while (semvalue < 0)
364366
{
365367
/* Wake up the thread */
366368

367369
nxsem_post(&group->tg_exitsem);
370+
nxsem_get_value(&group->tg_exitsem, &semvalue);
368371
}
369372
}
370373
}

0 commit comments

Comments
 (0)