mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
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:
+1
-13
@@ -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 */
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user