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

tests: kernel.condvar: child thread is not running #42723

Closed
zerosensei opened this issue Feb 11, 2022 · 2 comments · Fixed by #43031
Closed

tests: kernel.condvar: child thread is not running #42723

zerosensei opened this issue Feb 11, 2022 · 2 comments · Fixed by #43031
Assignees
Labels
area: Kernel area: Tests Issues related to a particular existing or missing test bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@zerosensei
Copy link

Describe the bug
The child thread is not actually running, main thread priority is -1, the two child threads have priorities 0 and 1, respectively.

#define PRIO_WAIT (CONFIG_ZTEST_THREAD_PRIORITY + 2)
#define PRIO_WAKE (CONFIG_ZTEST_THREAD_PRIORITY + 1)
void test_condvar_wait_forever_wake(void)
{
	woken = 1;
	timeout = K_TICKS_FOREVER;


	k_thread_create(&condvar_tid, stack_1, STACK_SIZE,
			condvar_wait_wake_task, &timeout, NULL, NULL,
			PRIO_WAIT, K_USER | K_INHERIT_PERMS, K_NO_WAIT);

	/* giving time for the condvar_wait_wake_task to execute */
	k_yield();

	k_thread_create(&condvar_wake_tid, condvar_wake_stack, STACK_SIZE,
			condvar_wake_task, &woken, NULL, NULL,
			PRIO_WAKE, K_USER | K_INHERIT_PERMS, K_MSEC(1));

	/* giving time for the condvar_wake_task
	 * and condvar_wait_wake_task to execute
	 */
	k_yield();

	k_thread_abort(&condvar_wake_tid);
	k_thread_abort(&condvar_tid);
}

So k_yield() does not cause the child thread to execute.

Environment (please complete the following information):

  • OS: Windows
  • Toolchain: Zephyr SDK
  • Commit SHA or Version used: v2.7.0-ncs1
@zerosensei zerosensei added the bug The issue is a bug, or the PR is fixing a bug label Feb 11, 2022
@LingaoM LingaoM added the area: Tests Issues related to a particular existing or missing test label Feb 11, 2022
@carlescufi carlescufi added area: Kernel priority: high High impact/importance bug labels Feb 11, 2022
@nashif nashif added priority: low Low impact/importance bug and removed priority: high High impact/importance bug labels Feb 11, 2022
@nashif
Copy link
Member

nashif commented Feb 11, 2022

should not be high, this is exact code from the test and all relates to test code and no some incorrect behavior of the implementation.

@chen-png
Copy link
Collaborator

chen-png commented Feb 14, 2022

this is not related to k_yield, it is the issue of this test design.
k_yield is used to give cpu access to those threads whose priority is higher or equal to current thread, but in this case, those two threads' priority is lower than current thread, so they won't be executed at all, this is correct, however, this isolates the design purpose of this test, it never runs child threads to test k_condar_wait with forever.

we could replace k_yield by k_sleep if we really want to run this tests.

nashif added a commit to nashif/zephyr that referenced this issue Feb 21, 2022
Fix priorities for the test threads to allow execution when test thread
yields.
Also cleanup some strings.

Fixes zephyrproject-rtos#42723

Signed-off-by: Anas Nashif <[email protected]>
nashif added a commit that referenced this issue Feb 22, 2022
Fix priorities for the test threads to allow execution when test thread
yields.
Also cleanup some strings.

Fixes #42723

Signed-off-by: Anas Nashif <[email protected]>
andrea-pallini pushed a commit to andrea-pallini/zephyr that referenced this issue Feb 23, 2022
Fix priorities for the test threads to allow execution when test thread
yields.
Also cleanup some strings.

Fixes zephyrproject-rtos#42723

Signed-off-by: Anas Nashif <[email protected]>
RodinHaker pushed a commit to abelsensors/zephyr that referenced this issue Mar 19, 2022
Fix priorities for the test threads to allow execution when test thread
yields.
Also cleanup some strings.

Fixes zephyrproject-rtos#42723

Signed-off-by: Anas Nashif <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Kernel area: Tests Issues related to a particular existing or missing test bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants