casaroli commented on code in PR #21424:
URL: https://github.com/apache/nuttx/pull/21424#discussion_r4548391943
##########
sched/sched/sched_critmonitor.c:
##########
@@ -370,30 +370,27 @@ void nxsched_critmon_busywait(bool state, FAR void
*caller)
void nxsched_switch_critmon(FAR struct tcb_s *from, FAR struct tcb_s *to)
{
- clock_t current = perf_gettime();
#if CONFIG_SCHED_CRITMONITOR_MAXTIME_THREAD >= 0
- clock_t elapsed = current - from->run_start;
-#else
- clock_t elapsed = 0;
-
- UNUSED(current);
- UNUSED(elapsed);
-#endif
+ irqstate_t flags = write_seqlock_irqsave(&g_thread_lock);
Review Comment:
The lock is per CPU now (g_thread_lock[cpu]), but clock_cpuload() on one CPU
also adds the running slice of the threads on all CPUs (it changes
g_thread_start[cpu] and run_time of another CPU), and clock_gettime() on
another CPU must read run_time and g_thread_start[cpu] of the same update, else
the CPU time goes back.
--
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]