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

Improve handling of tasks on BSP and AP CPUs #278

Merged
merged 5 commits into from
Jul 25, 2023

Conversation

wipawel
Copy link
Contributor

@wipawel wipawel commented Jul 21, 2023

No description provided.

@wipawel wipawel added the improvement A small enhancement, that makes already implemented features better label Jul 21, 2023
@wipawel wipawel requested a review from a team as a code owner July 21, 2023 11:27
wipawel added 5 commits July 21, 2023 13:30
Running test_main() as a task on BSP blocks scheduling and execution
of other tasks on BSP (chicken-egg problem), which get created and
scheduled from within the test_main() itself.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
In the wait_for_all_cpus() wait for all unfinished CPUs and/or CPUs
without empty task_queue. But do not wait for BSP as it typically
is the expected caller of this function.
Also, do not unlink CPU struct from the cpus list, there might be
more task upcoming.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
All AP CPUs after empting their task_queue get into blocked state, which
makes run_tasks() wait on them until they get unblocked. The BSP is
never waited on as it is supposed to unblock the AP CPUs.
After an unblock, run_tasks() sets the CPU into unfinished state, before
executing any tasks from the task_queue.

That way BSP controls when all APs start executing their tasks and when
they are finished with it.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
The execute_tasks() helper is responsible for collectively unblocking
all CPUs, calling run_tasks() on BSP CPU and waiting for all AP CPUs
untile they are finished.
In kernel_main the execute_tasks() is called before test_main() just
in case. Currently there are no tasks scheduled before the test_main().
The execute_tasks() called after the test_main() makes sure all APs and
the BSP get unblocked and their tasks executed or the states of the
CPUs are set to finished.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
@wipawel wipawel merged commit 3be17e6 into KernelTestFramework:mainline Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement A small enhancement, that makes already implemented features better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant