sem: remove limitation of irq context when do sem_trywait

Change-Id: I818c349d9396743877e99c5b04fc7265750a5ec3
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd
2021-09-27 15:52:03 +08:00
committed by liguiding1
parent b897d4a2d6
commit caee5581c2
2 changed files with 1 additions and 17 deletions
+1 -13
View File
@@ -75,18 +75,6 @@ void mm_seminitialize(FAR struct mm_heap_s *heap)
bool mm_takesemaphore(FAR struct mm_heap_s *heap)
{
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
/* Check current environment */
if (up_interrupt_context())
{
/* Can't take semaphore in the interrupt handler */
return false;
}
else
#endif
/* getpid() returns the task ID of the task at the head of the ready-to-
* run task list. mm_takesemaphore() may be called during context
* switches. There are certain situations during context switching when
@@ -102,7 +90,7 @@ bool mm_takesemaphore(FAR struct mm_heap_s *heap)
return false;
}
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
else if (sched_idletask())
else if (sched_idletask() || up_interrupt_context())
{
/* Try to take the semaphore */
-4
View File
@@ -69,10 +69,6 @@ int nxsem_trywait(FAR sem_t *sem)
irqstate_t flags;
int ret;
/* This API should not be called from interrupt handlers */
DEBUGASSERT(sem != NULL && up_interrupt_context() == false);
if (sem != NULL)
{
/* The following operations must be performed with interrupts disabled