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