Skip to content

kernel: timer: let k_timer_status_sync() idle the CPU when MT is off#101758

Merged
carlescufi merged 1 commit intozephyrproject-rtos:mainfrom
lemrey:ktimer-cpuidle
Jan 7, 2026
Merged

kernel: timer: let k_timer_status_sync() idle the CPU when MT is off#101758
carlescufi merged 1 commit intozephyrproject-rtos:mainfrom
lemrey:ktimer-cpuidle

Conversation

@lemrey
Copy link
Contributor

@lemrey lemrey commented Jan 5, 2026

This patch modifies k_timer_status_sync() to idle the CPU when MT is disabled, instead of busy-looping. For this purpose, the spinlock in the MULTITHREADING=n case has been reduced to a irq_lock(), which works in pair with k_cpu_atomic_idle() to ensure the atomicity of enabling the IRQs and idling the CPU.

See also #101192

This patch modifies k_timer_status_sync() to idle the CPU when MT
is disabled, instead of busy-looping. For this purpose, the spinlock
in the MULTITHREADING=n case has been reduced to a irq_lock(),
which works in pair with k_cpu_atomic_idle() to ensure the atomicity
of enabling the IRQs and idling the CPU.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
@lemrey lemrey changed the title kernel: timer: let k_timer_status_sync() idle the CPU when MT is off kernel: timer: let k_timer_status_sync() idle the CPU when MT is off Jan 5, 2026
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 5, 2026

Copy link
Contributor

@bjarki-andreasen bjarki-andreasen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@carlescufi carlescufi merged commit bc97315 into zephyrproject-rtos:main Jan 7, 2026
35 of 37 checks passed
@lemrey lemrey deleted the ktimer-cpuidle branch January 7, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants