Explicitly initialize the group tg_exitsem with sem_init(). The existing logic worked because the correct initialization value is all zero, but it is better to initialize the semaphore explicitly. Noted by Jouko Holopainen.

This commit is contained in:
Gregory Nutt 2016-08-10 07:37:25 -06:00
parent 4f87b4544e
commit 5ea77118aa
2 changed files with 12 additions and 1 deletions

View File

@ -241,12 +241,18 @@ int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype)
return ret;
}
#ifndef CONFIG_DISABLE_PTHREAD
/* Initialize the pthread join semaphore */
#ifndef CONFIG_DISABLE_PTHREAD
(void)sem_init(&group->tg_joinsem, 0, 1);
#endif
#if defined(CONFIG_SCHED_WAITPID) && !defined(CONFIG_SCHED_HAVE_PARENT)
/* Initialize the exit/wait semaphores */
(void)sem_init(&group->tg_exitsem, 0, 0);
#endif
return OK;
}

View File

@ -167,6 +167,11 @@ int nanosleep(FAR const struct timespec *rqtp, FAR struct timespec *rmtp)
systime_t remaining;
int ticks;
/* REVISIT: The conversion from time to ticks and back could
* be avoided. clock_timespec_subtract() would be used instead
* to get the time difference.
*/
/* First get the number of clock ticks that we were requested to
* wait.
*/