1 /*
2  * Copyright (c) 2018-2023 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef ZEPHYR_INCLUDE_POSIX_SCHED_H_
7 #define ZEPHYR_INCLUDE_POSIX_SCHED_H_
8 
9 #include <zephyr/kernel.h>
10 
11 #include "posix_types.h"
12 
13 #include <time.h>
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /*
20  * Other mandatory scheduling policy. Must be numerically distinct. May
21  * execute identically to SCHED_RR or SCHED_FIFO. For Zephyr this is a
22  * pseudonym for SCHED_RR.
23  */
24 #define SCHED_OTHER 0
25 
26 /* Cooperative scheduling policy */
27 #define SCHED_FIFO 1
28 
29 /* Priority based preemptive scheduling policy */
30 #define SCHED_RR 2
31 
32 #if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \
33 	|| defined(CONFIG_ARCMWDT_LIBC)
34 struct sched_param {
35 	int sched_priority;
36 };
37 #endif
38 
39 /**
40  * @brief Yield the processor
41  *
42  * See IEEE 1003.1
43  */
sched_yield(void)44 static inline int sched_yield(void)
45 {
46 	k_yield();
47 	return 0;
48 }
49 
50 int sched_get_priority_min(int policy);
51 int sched_get_priority_max(int policy);
52 
53 int sched_getparam(pid_t pid, struct sched_param *param);
54 int sched_getscheduler(pid_t pid);
55 
56 int sched_setparam(pid_t pid, const struct sched_param *param);
57 int sched_setscheduler(pid_t pid, int policy, const struct sched_param *param);
58 int sched_rr_get_interval(pid_t pid, struct timespec *interval);
59 
60 #ifdef __cplusplus
61 }
62 #endif
63 
64 #endif /* ZEPHYR_INCLUDE_POSIX_SCHED_H_ */
65