-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Labels
area: KernelbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bugMedium impact/importance bug
Description
Describe the bug
Bug in k_sleep implementation for no multi-threading mode.
Absolute value of timeout expiration was fed to the k_busy_wait() function instead of delta value. That caused bug like incrementing of sleep time in geometric progression (while actual function argument is constant) during program running.
Suggested solution
#80979
To Reproduce
- Replace
hello_worldsample source with simple code:
#include <zephyr/kernel.h>
int main (void)
{
uint32_t new_ticks = 0;
uint32_t old_ticks = sys_clock_tick_get_32();
while (1) {
k_sleep(K_MSEC(1000));
new_ticks = sys_clock_tick_get_32();
printf("%u\n", new_ticks - old_ticks);
old_ticks = new_ticks;
}
return 0;
}- write
CONFIG_MULTITHREADING=nflag inprj.conf cd zephyrwest build -b qemu-riscv64 samples/hello_worldwest build -t run- See, that waiting time between console outputs increases, even though constant value is passed into
k_sleep
Expected behavior
Expected, that k_sleep will wait actual amount of time, specified in function argument
Impact
Programs start to sleep a lot of time, when compile for no multi-threading mode
Logs and console output
Output from qemu_riscv64:
100
200
400
800
...
Environment (please complete the following information):
- OS: Linux
- Toolchain: zephyr-sdk-0.16.1
- Commit SHA or Version used: c3466b1
Additional context
NA
Metadata
Metadata
Assignees
Labels
area: KernelbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bugMedium impact/importance bug