You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/02/15 12:33:21 UTC

[GitHub] [incubator-nuttx] davids5 commented on a change in pull request #5504: mm: handle take mm sem in IRQ

davids5 commented on a change in pull request #5504:
URL: https://github.com/apache/incubator-nuttx/pull/5504#discussion_r806782591



##########
File path: mm/mm_heap/mm_sem.c
##########
@@ -104,9 +104,23 @@ bool mm_takesemaphore(FAR struct mm_heap_s *heap)
 #if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
   else if (sched_idletask())
     {
-      /* Try to take the semaphore */
+      return false;
+    }
+  else if (up_interrupt_context())
+    {
+      int val;
+
+#ifdef CONFIG_SMP
+      return false;
+#endif
+
+      /* Check the semaphore value, if held by someone, then return false.
+       * Else, we can take it, return true.
+       */
 
-      return _SEM_TRYWAIT(&heap->mm_semaphore) >= 0;
+      _SEM_GETVALUE(&heap->mm_semaphore, &val);
+
+      return val > 0;

Review comment:
       There is an opportunity to return false for SMP on entry - why not use it?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org