1 /*
2  * Copyright (c) 2006-2021, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  */
9 
10 #include <sched.h>
11 
sched_yield(void)12 int sched_yield(void)
13 {
14     rt_thread_yield();
15 
16     return 0;
17 }
18 RTM_EXPORT(sched_yield);
19 
sched_get_priority_min(int policy)20 int sched_get_priority_min(int policy)
21 {
22     if (policy != SCHED_FIFO && policy != SCHED_RR)
23         return EINVAL;
24 
25     return 0;
26 }
27 RTM_EXPORT(sched_get_priority_min);
28 
sched_get_priority_max(int policy)29 int sched_get_priority_max(int policy)
30 {
31     if (policy != SCHED_FIFO && policy != SCHED_RR)
32         return EINVAL;
33 
34     return RT_THREAD_PRIORITY_MAX - 1;
35 }
36 RTM_EXPORT(sched_get_priority_max);
37 
sched_setscheduler(pid_t pid,int policy)38 int sched_setscheduler(pid_t pid, int policy)
39 {
40     return EOPNOTSUPP;
41 }
42 RTM_EXPORT(sched_setscheduler);
43 
sched_rr_get_interval(pid_t pid,struct timespec * tp)44 int sched_rr_get_interval(pid_t pid, struct timespec *tp)
45 {
46     if(pid != 0)
47     {
48         return EINVAL;
49     }
50 
51     rt_set_errno(-EINVAL);
52 
53     /* course model, don't support */
54     // TODO
55     return -1;
56 }
57 RTM_EXPORT(sched_rr_get_interval);
58