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