Xenomai API  2.6.5
sched.h
1 /*
2  * Copyright (C) 2005 Philippe Gerum <[email protected]>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18 
19 #ifndef _XENO_POSIX_SCHED_H
20 #define _XENO_POSIX_SCHED_H
21 
22 #if defined(__KERNEL__) || defined(__XENO_SIM__)
23 
24 #include <nucleus/xenomai.h>
25 
26 #ifdef __KERNEL__
27 #include <linux/sched.h>
28 #endif /* __KERNEL__ */
29 
30 #ifdef __XENO_SIM__
31 #include <posix_overrides.h>
32 #define SCHED_FIFO 1
33 #define SCHED_RR 2
34 #endif /* __XENO_SIM__ */
35 
36 #define SCHED_OTHER 0
37 
38 struct timespec;
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 int sched_yield(void);
45 
46 int sched_get_priority_min(int policy);
47 
48 int sched_get_priority_max(int policy);
49 
50 int sched_rr_get_interval(int pid, struct timespec *interval);
51 
52 #ifdef __cplusplus
53 }
54 #endif
55 
56 #else /* !(__KERNEL__ || __XENO_SIM__) */
57 
58 #pragma GCC system_header
59 
60 #include_next <sched.h>
61 
62 int __real_sched_yield(void);
63 
64 #endif /* !(__KERNEL__ || __XENO_SIM__) */
65 
66 #ifndef __sched_extensions_defined
67 #define __sched_extensions_defined
68 
69 #ifndef SCHED_SPORADIC
70 #define SCHED_SPORADIC 10
71 #define sched_ss_low_priority sched_u.ss.__sched_low_priority
72 #define sched_ss_repl_period sched_u.ss.__sched_repl_period
73 #define sched_ss_init_budget sched_u.ss.__sched_init_budget
74 #define sched_ss_max_repl sched_u.ss.__sched_max_repl
75 #endif /* !SCHED_SPORADIC */
76 
77 struct __sched_ss_param {
78  int __sched_low_priority;
79  struct timespec __sched_repl_period;
80  struct timespec __sched_init_budget;
81  int __sched_max_repl;
82 };
83 
84 #ifndef SCHED_TP
85 #define SCHED_TP 11
86 #define sched_tp_partition sched_u.tp.__sched_partition
87 #endif /* !SCHED_TP */
88 
89 struct __sched_tp_param {
90  int __sched_partition;
91 };
92 
93 struct sched_param_ex {
94  int sched_priority;
95  union {
96  struct __sched_ss_param ss;
97  struct __sched_tp_param tp;
98  } sched_u;
99 };
100 
101 struct sched_tp_window {
102  struct timespec offset;
103  struct timespec duration;
104  int ptid;
105 };
106 
107 struct __sched_config_tp {
108  int nr_windows;
109  struct sched_tp_window windows[];
110 };
111 
112 union sched_config {
113  struct __sched_config_tp tp;
114 };
115 
116 #define sched_tp_confsz(nr_win) \
117  (sizeof(struct __sched_config_tp) + nr_win * sizeof(struct sched_tp_window))
118 
119 #ifdef __cplusplus
120 extern "C" {
121 #endif
122 
123 int sched_setconfig_np(int cpu, int policy,
124  union sched_config *config, size_t len);
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif /* __sched_extensions_defined */
131 
132 #endif /* SCHED_H */
int sched_rr_get_interval(int pid, struct timespec *interval)
Get the round-robin scheduling time slice.
Definition: sched.c:159
int sched_get_priority_min(int policy)
Get minimum priority of the specified scheduling policy.
Definition: sched.c:81
int sched_get_priority_max(int policy)
Get maximum priority of the specified scheduling policy.
Definition: sched.c:117
int sched_setconfig_np(int cpu, int policy, union sched_config *config, size_t len)
Load CPU-specific scheduler settings for a given policy.
Definition: sched.c:636
int sched_yield(void)
Yield the processor.
Definition: sched.c:512