Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel: k_sleep bug in no multi-threading mode #81210

Open
KushnerovMikhail opened this issue Nov 11, 2024 · 1 comment · May be fixed by #80979
Open

kernel: k_sleep bug in no multi-threading mode #81210

KushnerovMikhail opened this issue Nov 11, 2024 · 1 comment · May be fixed by #80979
Assignees
Labels
area: Kernel bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug

Comments

@KushnerovMikhail
Copy link

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

  1. Replace hello_world sample 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;
}
  1. write CONFIG_MULTITHREADING=n flag in prj.conf
  2. cd zephyr
  3. west build -b qemu-riscv64 samples/hello_world
  4. west build -t run
  5. 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

@KushnerovMikhail KushnerovMikhail added the bug The issue is a bug, or the PR is fixing a bug label Nov 11, 2024
Copy link

Hi @KushnerovMikhail! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

@mmahadevan108 mmahadevan108 added priority: low Low impact/importance bug priority: medium Medium impact/importance bug and removed priority: low Low impact/importance bug labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Kernel bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants