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/18 08:30:19 UTC

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

GUIDINGLI commented on a change in pull request #5539:
URL: https://github.com/apache/incubator-nuttx/pull/5539#discussion_r809773689



##########
File path: mm/mm_heap/mm_sem.c
##########
@@ -80,9 +80,21 @@ bool mm_takesemaphore(FAR struct mm_heap_s *heap)
 
   if (up_interrupt_context())
     {
-      /* Can't take semaphore in the interrupt handler */
+#if !defined(CONFIG_SMP) && defined(CONFIG_DEBUG_MM)
+      int val;
+
+      /* Check the semaphore value, if held by someone, then return false.
+       * Else, we can take it, return true.
+       */
+
+      _SEM_GETVALUE(&heap->mm_semaphore, &val);

Review comment:
       Yes, that's the change, but in @masayuki2009 's case, none will take mm_sem from IRQ context.
   And also, mm_takesemaphore will return false, when meet SMP mode.
   
   ```
    76 bool mm_takesemaphore(FAR struct mm_heap_s *heap)
    77 {
    78 #if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
    79   /* Check current environment */
    80 
    81   if (up_interrupt_context())
    82     {
    83 #if !defined(CONFIG_SMP) && defined(CONFIG_DEBUG_MM)
    84       int val;
    85 
    86       /* Check the semaphore value, if held by someone, then return false.
    87        * Else, we can take it, return true.
    88        */
    89 
    90       _SEM_GETVALUE(&heap->mm_semaphore, &val);
    91 
    92       return val > 0;
    93 #else
    94       /* Can't take semaphore in SMP interrupt handler */
    95 
    96       return false;
    97 #endif
    98     }
   ```
   




-- 
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