sim: fix loop add delaylist when mm_free in IDLE thread

Change-Id: I1827c663275f47c9dc30d63e17e3d016b0000166
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2021-07-02 15:22:54 +08:00 committed by Gustavo Henrique Nihei
parent 92210cbdcb
commit f5279f8583

View File

@ -212,21 +212,11 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size)
FAR void mm_free(FAR struct mm_heap_s *heap, FAR void *mem)
{
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
int ret = (int)getpid();
/* Check current environment */
if (up_interrupt_context())
if (getpid() == -ESRCH)
{
/* We are in ISR, add to mm_delaylist */
mm_add_delaylist(heap, mem);
}
else if (ret == -ESRCH || sched_idletask())
{
/* We are in IDLE task & can't get sem, or meet -ESRCH return,
* which means we are in situations during context switching(See
* mm_trysemaphore() & getpid()). Then add to mm_delaylist.
/* getpid() return -ESRCH, means we are in situations
* during context switching(See mm_trysemaphore() & getpid()).
* Then add to mm_delaylist.
*/
mm_add_delaylist(heap, mem);