SMP: Fix a IDLE task semaphore operation

This commit is contained in:
Gregory Nutt 2016-02-12 18:03:08 -06:00
parent 3f7f58de9d
commit f45166af32
2 changed files with 24 additions and 2 deletions

View File

@ -86,7 +86,7 @@
void mm_seminitialize(FAR struct mm_heap_s *heap)
{
/* Initialize the MM semaphore to one (to support one-at-a-time access to
* private data sets.
* private data sets).
*/
(void)sem_init(&heap->mm_semaphore, 0, 1);

View File

@ -98,12 +98,34 @@ int os_idletask(int argc, FAR char *argv[])
/* Finish TCB initialization */
FAR struct task_tcb_s *rtcb = (FAR struct task_tcb_s *)this_task();
int ret;
/* Create stdout, stderr, stdin on the IDLE task. These will be
* inherited by all of the threads created by the IDLE task.
*
* We must have exclusive access to the memory manager to do this BUT the
* idle task cannot wait on a semaphore (at least not later in the
* initialzation sequency when this thread is started). So loop until
* we do finally get access
*
*/
do
{
ret = kmm_trysemaphore();
if (ret >= 0)
{
DEBUGVERIFY(group_setupidlefiles(rtcb));
kmm_givesemaphore();
}
else
{
/* Perform any processor-specific idle state operations */
up_idle();
}
}
while (ret < 0);
#endif
/* Enter the IDLE loop */