1 | // SPDX-License-Identifier: GPL-3.0-or-later |
2 | |
3 | #pragma once |
4 | |
5 | #include <mos/tasks/task_types.h> |
6 | |
7 | __BEGIN_DECLS |
8 | |
9 | void tasks_init(); |
10 | |
11 | void scheduler_init(); |
12 | |
13 | char thread_state_str(thread_state_t state); |
14 | |
15 | /** |
16 | * @brief Unblock the scheduler, so that APs can start scheduling. |
17 | * |
18 | */ |
19 | void unblock_scheduler(void); |
20 | |
21 | /** |
22 | * @brief Enter the scheduler and switch to the next thread. |
23 | * |
24 | */ |
25 | [[noreturn]] void enter_scheduler(void); |
26 | |
27 | /** |
28 | * @brief Add a thread to the scheduler, so that it can be scheduled. |
29 | * |
30 | * @param thread |
31 | */ |
32 | void scheduler_add_thread(thread_t *thread); |
33 | |
34 | /** |
35 | * @brief Remove a thread from the scheduler. |
36 | * |
37 | * @param thread |
38 | */ |
39 | void scheduler_remove_thread(thread_t *thread); |
40 | |
41 | /** |
42 | * @brief Wake a thread. |
43 | * |
44 | * @param thread |
45 | */ |
46 | void scheduler_wake_thread(thread_t *thread); |
47 | |
48 | /** |
49 | * @brief reschedule. |
50 | * @warning The caller must have the current thread's state_lock acquired. |
51 | */ |
52 | void reschedule(void); |
53 | |
54 | /** |
55 | * @brief Mark the current task as blocked and reschedule. |
56 | * |
57 | */ |
58 | void blocked_reschedule(void); |
59 | |
60 | __nodiscard bool reschedule_for_waitlist(waitlist_t *waitlist); |
61 | |
62 | __END_DECLS |
63 | |