sem: remove limitation of irq context when do sem_trywait

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2021-09-27 15:52:03 +08:00 committed by Xiang Xiao
parent 17b67093cb
commit 7c547b3ebd
2 changed files with 6 additions and 0 deletions

View File

@ -80,9 +80,13 @@ bool mm_takesemaphore(FAR struct mm_heap_s *heap)
if (up_interrupt_context())
{
#ifdef CONFIG_DEBUG_MM
return _SEM_TRYWAIT(&heap->mm_semaphore) >= 0;
#else
/* Can't take semaphore in the interrupt handler */
return false;
#endif
}
else
#endif

View File

@ -69,9 +69,11 @@ int nxsem_trywait(FAR sem_t *sem)
irqstate_t flags;
int ret;
#ifndef CONFIG_DEBUG_MM
/* This API should not be called from interrupt handlers */
DEBUGASSERT(sem != NULL && up_interrupt_context() == false);
#endif
if (sem != NULL)
{