1 | .. SPDX-License-Identifier: CC-BY-SA-4.0 |
---|
2 | |
---|
3 | .. Copyright (C) 1988, 2002 On-Line Applications Research Corporation (OAR) |
---|
4 | |
---|
5 | Scheduler Manager |
---|
6 | ################# |
---|
7 | |
---|
8 | Introduction |
---|
9 | ============ |
---|
10 | |
---|
11 | The scheduler manager ... |
---|
12 | |
---|
13 | The directives provided by the scheduler manager are: |
---|
14 | |
---|
15 | - sched_get_priority_min_ - Get Minimum Priority Value |
---|
16 | |
---|
17 | - sched_get_priority_max_ - Get Maximum Priority Value |
---|
18 | |
---|
19 | - sched_rr_get_interval_ - Get Timeslicing Quantum |
---|
20 | |
---|
21 | - sched_yield_ - Yield the Processor |
---|
22 | |
---|
23 | Background |
---|
24 | ========== |
---|
25 | |
---|
26 | Priority |
---|
27 | -------- |
---|
28 | |
---|
29 | In the RTEMS implementation of the POSIX API, the priorities range from the low |
---|
30 | priority of ``sched_get_priority_min()`` to the highest priority of |
---|
31 | ``sched_get_priority_max()``. Numerically higher values represent higher |
---|
32 | priorities. |
---|
33 | |
---|
34 | Scheduling Policies |
---|
35 | ------------------- |
---|
36 | |
---|
37 | The following scheduling policies are available: |
---|
38 | |
---|
39 | *SCHED_FIFO* |
---|
40 | Priority-based, preemptive scheduling with no timeslicing. This is |
---|
41 | equivalent to what is called "manual round-robin" scheduling. |
---|
42 | |
---|
43 | *SCHED_RR* |
---|
44 | Priority-based, preemptive scheduling with timeslicing. Time quantums are |
---|
45 | maintained on a per-thread basis and are not reset at each context switch. |
---|
46 | Thus, a thread which is preempted and subsequently resumes execution will |
---|
47 | attempt to complete the unused portion of its time quantum. |
---|
48 | |
---|
49 | *SCHED_OTHER* |
---|
50 | Priority-based, preemptive scheduling with timeslicing. Time quantums are |
---|
51 | maintained on a per-thread basis and are reset at each context switch. |
---|
52 | |
---|
53 | *SCHED_SPORADIC* |
---|
54 | Priority-based, preemptive scheduling utilizing three additional |
---|
55 | parameters: budget, replenishment period, and low priority. Under this |
---|
56 | policy, the thread is allowed to execute for "budget" amount of time before |
---|
57 | its priority is lowered to "low priority". At the end of each replenishment |
---|
58 | period, the thread resumes its initial priority and has its budget |
---|
59 | replenished. |
---|
60 | |
---|
61 | Operations |
---|
62 | ========== |
---|
63 | |
---|
64 | There is currently no text in this section. |
---|
65 | |
---|
66 | Directives |
---|
67 | ========== |
---|
68 | |
---|
69 | This section details the scheduler manager's directives. A subsection is |
---|
70 | dedicated to each of this manager's directives and describes the calling |
---|
71 | sequence, related constants, usage, and status codes. |
---|
72 | |
---|
73 | .. _sched_get_priority_min: |
---|
74 | |
---|
75 | sched_get_priority_min - Get Minimum Priority Value |
---|
76 | --------------------------------------------------- |
---|
77 | .. index:: sched_get_priority_min |
---|
78 | .. index:: get minimum priority value |
---|
79 | |
---|
80 | **CALLING SEQUENCE:** |
---|
81 | |
---|
82 | .. code-block:: c |
---|
83 | |
---|
84 | #include <sched.h> |
---|
85 | int sched_get_priority_min( |
---|
86 | int policy |
---|
87 | ); |
---|
88 | |
---|
89 | **STATUS CODES:** |
---|
90 | |
---|
91 | On error, this routine returns -1 and sets ``errno`` to one of the following: |
---|
92 | |
---|
93 | .. list-table:: |
---|
94 | :class: rtems-table |
---|
95 | |
---|
96 | * - ``EINVAL`` |
---|
97 | - The indicated policy is invalid. |
---|
98 | |
---|
99 | **DESCRIPTION:** |
---|
100 | |
---|
101 | This routine return the minimum (numerically and logically lowest) priority for |
---|
102 | the specified ``policy``. |
---|
103 | |
---|
104 | **NOTES:** |
---|
105 | |
---|
106 | NONE |
---|
107 | |
---|
108 | .. _sched_get_priority_max: |
---|
109 | |
---|
110 | sched_get_priority_max - Get Maximum Priority Value |
---|
111 | --------------------------------------------------- |
---|
112 | .. index:: sched_get_priority_max |
---|
113 | .. index:: get maximum priority value |
---|
114 | |
---|
115 | **CALLING SEQUENCE:** |
---|
116 | |
---|
117 | .. code-block:: c |
---|
118 | |
---|
119 | #include <sched.h> |
---|
120 | int sched_get_priority_max( |
---|
121 | int policy |
---|
122 | ); |
---|
123 | |
---|
124 | **STATUS CODES:** |
---|
125 | |
---|
126 | On error, this routine returns -1 and sets ``errno`` to one of the following: |
---|
127 | |
---|
128 | .. list-table:: |
---|
129 | :class: rtems-table |
---|
130 | |
---|
131 | * - ``EINVAL`` |
---|
132 | - The indicated policy is invalid. |
---|
133 | |
---|
134 | **DESCRIPTION:** |
---|
135 | |
---|
136 | This routine return the maximum (numerically and logically highest) priority |
---|
137 | for the specified ``policy``. |
---|
138 | |
---|
139 | **NOTES:** |
---|
140 | |
---|
141 | NONE |
---|
142 | |
---|
143 | .. _sched_rr_get_interval: |
---|
144 | |
---|
145 | sched_rr_get_interval - Get Timeslicing Quantum |
---|
146 | ----------------------------------------------- |
---|
147 | .. index:: sched_rr_get_interval |
---|
148 | .. index:: get timeslicing quantum |
---|
149 | |
---|
150 | **CALLING SEQUENCE:** |
---|
151 | |
---|
152 | .. code-block:: c |
---|
153 | |
---|
154 | #include <sched.h> |
---|
155 | int sched_rr_get_interval( |
---|
156 | pid_t pid, |
---|
157 | struct timespec *interval |
---|
158 | ); |
---|
159 | |
---|
160 | **STATUS CODES:** |
---|
161 | |
---|
162 | On error, this routine returns -1 and sets ``errno`` to one of the following: |
---|
163 | |
---|
164 | .. list-table:: |
---|
165 | :class: rtems-table |
---|
166 | |
---|
167 | * - ``ESRCH`` |
---|
168 | - The indicated process id is invalid. |
---|
169 | * - ``EINVAL`` |
---|
170 | - The specified interval pointer parameter is invalid. |
---|
171 | |
---|
172 | **DESCRIPTION:** |
---|
173 | |
---|
174 | This routine returns the length of the timeslice quantum in the ``interval`` |
---|
175 | parameter for the specified ``pid``. |
---|
176 | |
---|
177 | **NOTES:** |
---|
178 | |
---|
179 | The ``pid`` argument should be 0 to indicate the calling process. |
---|
180 | |
---|
181 | .. _sched_yield: |
---|
182 | |
---|
183 | sched_yield - Yield the Processor |
---|
184 | --------------------------------- |
---|
185 | .. index:: sched_yield |
---|
186 | .. index:: yield the processor |
---|
187 | |
---|
188 | **CALLING SEQUENCE:** |
---|
189 | |
---|
190 | .. code-block:: c |
---|
191 | |
---|
192 | #include <sched.h> |
---|
193 | int sched_yield( void ); |
---|
194 | |
---|
195 | **STATUS CODES:** |
---|
196 | |
---|
197 | This routine always returns zero to indicate success. |
---|
198 | |
---|
199 | **DESCRIPTION:** |
---|
200 | |
---|
201 | This call forces the calling thread to yield the processor to another |
---|
202 | thread. Normally this is used to implement voluntary round-robin task |
---|
203 | scheduling. |
---|
204 | |
---|
205 | **NOTES:** |
---|
206 | |
---|
207 | NONE |
---|