GUIDINGLI commented on pull request #5539:
URL: https://github.com/apache/incubator-nuttx/pull/5539#issuecomment-1046713485


   > I already pointed out the code that is affected by removal of 
`_SEM_TRYWAIT(&heap->mm_semaphore) >= 0;` from a `else if (sched_idletask())`. 
The case now will be always hit. I'm not sure is this will bring any issues and 
just want to be sure that we find and review impact in all possible places.
   > 
   > ```
   >   if (mm_takesemaphore(heap) == false)
   >     {
   >       kasan_unpoison(mem, mm_malloc_size(mem));
   > 
   >       /* We are in IDLE task & can't get sem, or meet -ESRCH return,
   >        * which means we are in situations during context switching(See
   >        * mm_takesemaphore() & getpid()). Then add to the delay list.
   >        */
   > 
   >       mm_add_delaylist(heap, mem);
   >       return;
   >     }
   > ```
   
   We always use `malloc/free` at system init idle (like some initialize...), 
and at this time we allow user use `sem_wait/trywait`.
   But we don't let users use `sem_wait/trywait` in idle loop, that is the real 
idle thread.
   
   So, I commit another patch:
   
   ```
   Author: ligd <[email protected]>
   Date:   Mon Feb 21 18:14:10 2022 +0800
   
       os init_state: add new state OSINIT_OSIDLELOOP
       
       This is for distinguish we are in init idle or idle loop.
       Use for assertion for sem_trywait & sem_wait
       
       Signed-off-by: ligd <[email protected]>
   ```
   
   


-- 
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]


Reply via email to