Skip to content

Commit

Permalink
sched: add execute_tasks() helper function
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
wipawel committed Jul 21, 2023
1 parent 8e8bbe1 commit 3dbbe7a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions common/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ void kernel_main(void) {
display_multiboot_mmap();
}

test_main(NULL);
run_tasks(cpu);
unblock_all_cpus();
wait_for_all_cpus();
execute_tasks();

test_main(NULL);
printk("All tasks done.\n");

execute_tasks();

#ifdef KTF_PMU
pfm_terminate();
#endif
Expand Down
5 changes: 5 additions & 0 deletions include/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,9 @@ static inline task_t *new_user_task(const char *name, task_func_t func, void *ar
return new_task(name, func, arg, TASK_TYPE_USER);
}

static inline void execute_tasks(void) {
unblock_all_cpus();
run_tasks(get_bsp_cpu());
wait_for_all_cpus();
}
#endif /* KTF_SCHED_H */
2 changes: 2 additions & 0 deletions tests/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ unsigned long test_main(void *unused) {

printk("Running test: %s\n", name);
rc = fn(NULL);
execute_tasks();

printk("Test %s returned: 0x%x\n", name, rc);
n++;
}
Expand Down

0 comments on commit 3dbbe7a

Please sign in to comment.