anchao commented on code in PR #14578:
URL: https://github.com/apache/nuttx/pull/14578#discussion_r1860224762


##########
sched/irq/irq_csection.c:
##########
@@ -440,22 +435,40 @@ void leave_critical_section(irqstate_t flags)
        */
 
       DEBUGASSERT(rtcb->irqcount > 0);
-      if (--rtcb->irqcount <= 0)
-        {
-          /* Note that we have left the critical section */
-
-#if CONFIG_SCHED_CRITMONITOR_MAXTIME_CSECTION >= 0
-          nxsched_critmon_csection(rtcb, false, return_address(0));
-#endif
-#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
-          sched_note_csection(rtcb, false);
-#endif
-        }
+      --rtcb->irqcount;
     }
 
   /* Restore the previous interrupt state. */
 
   up_irq_restore(flags);
 }
 #endif
+
+#if CONFIG_SCHED_CRITMONITOR_MAXTIME_CSECTION >= 0 ||\
+    defined(CONFIG_SCHED_INSTRUMENTATION_CSECTION)
+void leave_critical_section(irqstate_t flags)
+{
+  FAR struct tcb_s *rtcb;
+
+  leave_critical_section_wo_note(flags);

Review Comment:
   ```suggestion
   
   ```



##########
sched/irq/irq_csection.c:
##########
@@ -440,22 +435,40 @@ void leave_critical_section(irqstate_t flags)
        */
 
       DEBUGASSERT(rtcb->irqcount > 0);
-      if (--rtcb->irqcount <= 0)
-        {
-          /* Note that we have left the critical section */
-
-#if CONFIG_SCHED_CRITMONITOR_MAXTIME_CSECTION >= 0
-          nxsched_critmon_csection(rtcb, false, return_address(0));
-#endif
-#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
-          sched_note_csection(rtcb, false);
-#endif
-        }
+      --rtcb->irqcount;
     }
 
   /* Restore the previous interrupt state. */
 
   up_irq_restore(flags);
 }
 #endif
+
+#if CONFIG_SCHED_CRITMONITOR_MAXTIME_CSECTION >= 0 ||\
+    defined(CONFIG_SCHED_INSTRUMENTATION_CSECTION)
+void leave_critical_section(irqstate_t flags)
+{
+  FAR struct tcb_s *rtcb;
+
+  leave_critical_section_wo_note(flags);
+
+  rtcb = this_task();
+  if (rtcb->irqcount == 0)
+    {
+      irqstate_t flags_wo_note;
+
+      flags_wo_note = enter_critical_section_wo_note();

Review Comment:
   ```suggestion
   
   ```



##########
sched/irq/irq_csection.c:
##########
@@ -440,22 +435,40 @@ void leave_critical_section(irqstate_t flags)
        */
 
       DEBUGASSERT(rtcb->irqcount > 0);
-      if (--rtcb->irqcount <= 0)
-        {
-          /* Note that we have left the critical section */
-
-#if CONFIG_SCHED_CRITMONITOR_MAXTIME_CSECTION >= 0
-          nxsched_critmon_csection(rtcb, false, return_address(0));
-#endif
-#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
-          sched_note_csection(rtcb, false);
-#endif
-        }
+      --rtcb->irqcount;
     }
 
   /* Restore the previous interrupt state. */
 
   up_irq_restore(flags);
 }
 #endif
+
+#if CONFIG_SCHED_CRITMONITOR_MAXTIME_CSECTION >= 0 ||\
+    defined(CONFIG_SCHED_INSTRUMENTATION_CSECTION)
+void leave_critical_section(irqstate_t flags)
+{
+  FAR struct tcb_s *rtcb;
+
+  leave_critical_section_wo_note(flags);
+
+  rtcb = this_task();
+  if (rtcb->irqcount == 0)

Review Comment:
   should check up_interrupt_context()



##########
sched/irq/irq_csection.c:
##########
@@ -285,27 +276,41 @@ irqstate_t enter_critical_section(void)
        */
 
       DEBUGASSERT(rtcb->irqcount >= 0 && rtcb->irqcount < INT16_MAX);
-      if (++rtcb->irqcount == 1)
-        {
-          /* Note that we have entered the critical section */
+      rtcb->irqcount++;
+    }
 
+  /* Return interrupt status */
+
+  return ret;
+}
+#endif
+
+#if CONFIG_SCHED_CRITMONITOR_MAXTIME_CSECTION >= 0 ||\
+    defined(CONFIG_SCHED_INSTRUMENTATION_CSECTION)
+irqstate_t enter_critical_section(void)
+{
+  FAR struct tcb_s *rtcb;
+  irqstate_t flags;
+  flags = enter_critical_section_wo_note();
+
+  rtcb = this_task();
+  if (rtcb->irqcount == 1)

Review Comment:
   need check up_interrupt_context()



-- 
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-unsubscr...@nuttx.apache.org

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

Reply via email to