xiaoxiang781216 commented on code in PR #22164:
URL: https://github.com/apache/nuttx/pull/22164#discussion_r4661078306
##########
sched/wqueue/wqueue.h:
##########
@@ -155,6 +155,38 @@ static inline_function FAR struct kwork_wqueue_s
*work_qid2wq(int qid)
}
}
+/****************************************************************************
+ * Name: work_lock/work_unlock
+ *
+ * Description:
+ * Lock and unlock the work queues and the work notifier.
+ *
+ * With the queue locked, the work queue code starts and stops the queue
+ * timer and wakes the workers: wd_start(), wd_cancel() and nxsem_post()
+ * enter the critical section. Code that is in the critical section
+ * (task exit, watchdog callbacks, drivers) queues and cancels work. So
+ * the critical section is the lock: a separate spinlock, taken in the
+ * two orders, stops two CPUs.
+ *
+ * Preemption stays disabled, so that a woken worker cannot run on this
+ * CPU before the caller unlocks.
+ *
+ ****************************************************************************/
+
+static inline_function irqstate_t work_lock(void)
+{
+ irqstate_t flags = enter_critical_section();
Review Comment:
could we avoid using the global critical section? it's a kernel big lock
which will impact SMP performance.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]