You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/11/17 08:20:14 UTC

[incubator-nuttx] branch master updated: sem: remove limitation of irq context when do sem_trywait

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 7c547b3  sem: remove limitation of irq context when do sem_trywait
7c547b3 is described below

commit 7c547b3ebdaa1d4d13d0f64b523bbbd8299fc5a4
Author: ligd <li...@xiaomi.com>
AuthorDate: Mon Sep 27 15:52:03 2021 +0800

    sem: remove limitation of irq context when do sem_trywait
    
    Signed-off-by: ligd <li...@xiaomi.com>
---
 mm/mm_heap/mm_sem.c           | 4 ++++
 sched/semaphore/sem_trywait.c | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/mm/mm_heap/mm_sem.c b/mm/mm_heap/mm_sem.c
index a4d4e86..b7c64b7 100644
--- a/mm/mm_heap/mm_sem.c
+++ b/mm/mm_heap/mm_sem.c
@@ -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
diff --git a/sched/semaphore/sem_trywait.c b/sched/semaphore/sem_trywait.c
index 3648aac..00f8b59 100644
--- a/sched/semaphore/sem_trywait.c
+++ b/sched/semaphore/sem_trywait.c
@@ -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)
     {