1/* @title: Realtime scheduling types */
2#pragma once
3#include <stdint.h>
4/* This enum defines *what* the realtime scheduler will tell you from
5 * functions. For example, when it summarizes itself and produces a
6 * `struct rt_thread_summary` it will also send along an error
7 * with it, denoting any internal happening, e.g. not being able
8 * to migrate threads because of deadline reasons... */
9enum rt_scheduler_error {
10 /* Ranges:
11 *
12 * [-20, -11] = general failures
13 *
14 * [-10, -1] = migration failures
15 * 0 = success (no message)
16 * [1, 10] = migration success with message
17 *
18 * [11, 20] = general success with message
19 */
20
21 RT_SCHEDULER_ERR_FAIL_ASAP = -20, /* Tell the core scheduler
22 * to fail the RT scheduler */
23
24 RT_SCHEDULER_ERR_INCOMPATIBLE = -19, /* No compatible CPU
25 * found for thread */
26
27 RT_SCHEDULER_ERR_SWITCH_IMPOSSIBLE = -18, /* Switching the scheduler would
28 * lead to unhoused threads */
29
30 RT_SCHEDULER_ERR_OOM = -17, /* Specifically ran out of memory */
31
32 RT_SCHEDULER_ERR_OOR = -16, /* Generic "Out of resources" */
33 RT_SCHEDULER_ERR_NOT_FOUND = -15, /* cannot find it */
34 RT_SCHEDULER_ERR_INVALID = -14, /* Invalid operation */
35 RT_SCHEDULER_ERR_UNKNOWN = -13,
36
37 RT_SCHEDULER_ERR_POLICY = -3,
38 RT_SCHEDULER_ERR_DEADLINE = -2, /* Deadline-related error */
39
40 RT_SCHEDULER_ERR_AFFINITY = -1, /* All threads are pinned/
41 * unmigratable... so there's
42 * nothing we can do anyways */
43
44 RT_SCHEDULER_ERR_OK = 0,
45
46};
47
48/* rt_scheduler_capability: 16 bit bitflags:
49 *
50 * ┌───────────────────────────┐
51 * Bits │ 15..12 11..8 7..4 3..0 │
52 * Use │ XAAA **** ***M DERF │
53 * └───────────────────────────┘
54 *
55 * F - First In, First Out
56 * R - Round-Robin
57 * E - Earliest Deadline First
58 * D - Deadline Capable
59 * M - Migration Capable
60 * X - !!! FAULT TOLERANT !!! ALL THREADS UNDER THIS SCHEDULER
61 * MUST ALSO BE FAULT TOLERANT, ELSE THEY WILL NOT RUN!!!
62 *
63 * A - Unused (Available)
64 * * - Unused (Unavailable)
65 *
66 */
67enum rt_scheduler_capability : uint16_t {
68 RT_CAP_FIFO = 1 << 0,
69 RT_CAP_RR = 1 << 1,
70 RT_CAP_EDF = 1 << 2,
71 RT_CAP_DEADLINE = 1 << 3,
72 RT_CAP_MIGRATABLE = 1 << 4,
73 RT_CAP_FAULT_TOLERANT = 1 << 15,
74};
75