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
9void tasks_init();
10
11void scheduler_init();
12
13char thread_state_str(thread_state_t state);
14
15/**
16 * @brief Unblock the scheduler, so that APs can start scheduling.
17 *
18 */
19void 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 */
32void scheduler_add_thread(thread_t *thread);
33
34/**
35 * @brief Remove a thread from the scheduler.
36 *
37 * @param thread
38 */
39void scheduler_remove_thread(thread_t *thread);
40
41/**
42 * @brief Wake a thread.
43 *
44 * @param thread
45 */
46void 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 */
52void reschedule(void);
53
54/**
55 * @brief Mark the current task as blocked and reschedule.
56 *
57 */
58void blocked_reschedule(void);
59
60__nodiscard bool reschedule_for_waitlist(waitlist_t *waitlist);
61
62__END_DECLS
63