Skip to content

k_cycle_get_32() API is useless in some Zephyr configurations #16238

@pizi-nordic

Description

@pizi-nordic

TL;DR:
CONFIG_USERSPACE=y + CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y = No reference for k_cycle_get_32().

The CONFIG_USERSPACE option introduces strong separation between the application and the
kernel memory. The CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME makes the CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC define useless leaving the sys_clock_hw_cycles_per_sec() function the only source of system timer frequency, which is needed to interpret data from k_cycle_get_32().

Unfortunately, the sys_clock_hw_cycles_per_sec() function directly reads the kernel memory (z_clock_hw_cycles_per_sec) triggering exception when called from user thread.

Please also note, that sys_clock_hw_cycles_per_sec() is used in multiple inline functions, so other timing-related API also fails with the mentioned configuration.

Metadata

Metadata

Assignees

Labels

area: APIChanges to public APIsarea: KernelbugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions