File: group__posix__sched.html

package info (click to toggle)
xenomai 2.4.4-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 29,316 kB
  • ctags: 23,320
  • sloc: ansic: 75,366; sh: 10,477; makefile: 1,672; xml: 1,356; asm: 607; php: 316; perl: 155
file content (341 lines) | stat: -rw-r--r-- 19,217 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Xenomai API: Threads scheduling services.</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
            <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
          </tr>
        </table>
      </form>
    </li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>Threads scheduling services.<br>
<small>
[<a class="el" href="group__posix__thread.html">Threads management services.</a>]</small>
</h1>
<p>
<div class="dynheader">
Collaboration diagram for Threads scheduling services.:</div>
<div class="dynsection">
<center><table><tr><td><img src="group__posix__sched.png" border="0" alt="" usemap="#group____posix____sched_map">
<map name="group____posix____sched_map">
<area shape="rect" href="group__posix__thread.html" title="Threads management services." alt="" coords="7,6,209,30"></map></td></tr></table></center>
</div>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Thread scheduling services. 
<p>
Xenomai POSIX skin supports the scheduling policies SCHED_FIFO, SCHED_RR and SCHED_OTHER.<p>
The SCHED_OTHER policy is mainly useful for user-space non-realtime activities that need to synchronize with real-time activities.<p>
The SCHED_RR policy is only effective if the time base is periodic (i.e. if configured with the compilation constant <em>CONFIG_XENO_OPT_POSIX_PERIOD</em> or the <em>xeno_nucleus</em> module parameter <em>tick_arg</em> set to a non null value). The SCHED_RR round-robin time slice is configured with the <em>xeno_posix</em> module parameter <em>time_slice</em>, as a count of system timer clock ticks.<p>
The SCHED_SPORADIC policy is not supported.<p>
The scheduling policy and priority of a thread is set when creating a thread, by using thread creation attributes (see <a class="el" href="group__posix__threadattr.html#gd437fe8caa3ef9f0cb7d69f6f6479df9" title="Set inheritsched attribute.">pthread_attr_setinheritsched()</a>, <a class="el" href="group__posix__threadattr.html#g79b4c9e71486a87ef3014f1c660b33eb" title="Set schedpolicy attribute.">pthread_attr_setschedpolicy()</a> and <a class="el" href="group__posix__threadattr.html#g7d0bf4f0734aca888f89f7341b1df222" title="Set schedparam attribute.">pthread_attr_setschedparam()</a>), or when the thread is already running by using the service <a class="el" href="group__posix__sched.html#g95276f88e1a2cae7a37f792123a99144" title="Set the scheduling policy and parameters of the specified thread.">pthread_setschedparam()</a>.<p>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/xsh_chap02_08.html#tag_02_08_04">Specification.</a> </dd></dl>

<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__posix__sched.html#gf1f370fc36ea6b22ed42b5ee3cf82a81">sched_get_priority_min</a> (int policy)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get minimum priority of the specified scheduling policy.  <a href="#gf1f370fc36ea6b22ed42b5ee3cf82a81"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__posix__sched.html#gfaebd1698caeb9b9b9e614ad84edd609">sched_get_priority_max</a> (int policy)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get maximum priority of the specified scheduling policy.  <a href="#gfaebd1698caeb9b9b9e614ad84edd609"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__posix__sched.html#gf8bce87eeeae4d7e356b0a2d7ef09082">sched_rr_get_interval</a> (int pid, struct timespec *interval)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the round-robin scheduling time slice.  <a href="#gf8bce87eeeae4d7e356b0a2d7ef09082"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__posix__sched.html#gbe5d6e7c9f3293447657b3a6f7d25282">pthread_getschedparam</a> (pthread_t tid, int *pol, struct sched_param *par)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Get the scheduling policy and parameters of the specified thread.  <a href="#gbe5d6e7c9f3293447657b3a6f7d25282"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__posix__sched.html#g95276f88e1a2cae7a37f792123a99144">pthread_setschedparam</a> (pthread_t tid, int pol, const struct sched_param *par)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the scheduling policy and parameters of the specified thread.  <a href="#g95276f88e1a2cae7a37f792123a99144"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__posix__sched.html#g357cd4b34c13011749dfffb42b489f09">sched_yield</a> (void)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Yield the processor.  <a href="#g357cd4b34c13011749dfffb42b489f09"></a><br></td></tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="gbe5d6e7c9f3293447657b3a6f7d25282"></a><!-- doxytag: member="sched.c::pthread_getschedparam" ref="gbe5d6e7c9f3293447657b3a6f7d25282" args="(pthread_t tid, int *pol, struct sched_param *par)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int pthread_getschedparam           </td>
          <td>(</td>
          <td class="paramtype">pthread_t&nbsp;</td>
          <td class="paramname"> <em>tid</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&nbsp;</td>
          <td class="paramname"> <em>pol</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct sched_param *&nbsp;</td>
          <td class="paramname"> <em>par</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the scheduling policy and parameters of the specified thread. 
<p>
This service returns, at the addresses <em>pol</em> and <em>par</em>, the current scheduling policy and scheduling parameters (i.e. priority) of the Xenomai POSIX skin thread <em>tid</em>. If this service is called from user-space and <em>tid</em> is not the identifier of a Xenomai POSIX skin thread, this service fallback to Linux regular pthread_getschedparam service.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>tid</em>&nbsp;</td><td>target thread;</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>pol</em>&nbsp;</td><td>address where the scheduling policy of <em>tid</em> is stored on success;</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>par</em>&nbsp;</td><td>address where the scheduling parameters of <em>tid</em> is stored on success.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 on success; <p>
an error number if:<ul>
<li>ESRCH, <em>tid</em> is invalid.</li></ul>
</dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/pthread_getschedparam.html">Specification.</a> </dd></dl>

<p>References <a class="el" href="include_2nucleus_2thread_8h-source.html#l00048">XNRRB</a>.</p>

<p>Referenced by <a class="el" href="skins_2posix_2thread_8c-source.html#l00152">pthread_create()</a>.</p>

</div>
</div><p>
<a class="anchor" name="g95276f88e1a2cae7a37f792123a99144"></a><!-- doxytag: member="sched.c::pthread_setschedparam" ref="g95276f88e1a2cae7a37f792123a99144" args="(pthread_t tid, int pol, const struct sched_param *par)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int pthread_setschedparam           </td>
          <td>(</td>
          <td class="paramtype">pthread_t&nbsp;</td>
          <td class="paramname"> <em>tid</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>pol</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const struct sched_param *&nbsp;</td>
          <td class="paramname"> <em>par</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Set the scheduling policy and parameters of the specified thread. 
<p>
This service set the scheduling policy of the Xenomai POSIX skin thread <em>tid</em> to the value <em>pol</em>, and its scheduling parameters (i.e. its priority) to the value pointed to by <em>par</em>.<p>
When used in user-space, passing the current thread ID as <em>tid</em> argument, this service turns the current thread into a Xenomai POSIX skin thread. If <em>tid</em> is neither the identifier of the current thread nor the identifier of a Xenomai POSIX skin thread this service falls back to the regular <a class="el" href="group__posix__sched.html#g95276f88e1a2cae7a37f792123a99144" title="Set the scheduling policy and parameters of the specified thread.">pthread_setschedparam()</a> service, hereby causing the current thread to switch to secondary mode if it is Xenomai thread.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>tid</em>&nbsp;</td><td>target thread;</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>pol</em>&nbsp;</td><td>scheduling policy, one of SCHED_FIFO, SCHED_RR or SCHED_OTHER;</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>par</em>&nbsp;</td><td>scheduling parameters address.</td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 on success; <p>
an error number if:<ul>
<li>ESRCH, <em>tid</em> is invalid;</li><li>EINVAL, <em>pol</em> or <em>par-&gt;sched_priority</em> is invalid;</li><li>EAGAIN, in user-space, insufficient memory exists in the system heap, increase CONFIG_XENO_OPT_SYS_HEAPSZ;</li><li>EFAULT, in user-space, <em>par</em> is an invalid address;</li><li>EPERM, in user-space, the calling process does not have superuser permissions.</li></ul>
</dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/pthread_setschedparam.html">Specification.</a> </dd></dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="rtcan__rtt_8c-example.html#a3">rtcan_rtt.c</a>.</dl>
<p>References <a class="el" href="pod_8c-source.html#l01784">xnpod_renice_thread()</a>, <a class="el" href="pod_8c-source.html#l02377">xnpod_schedule()</a>, <a class="el" href="pod_8c-source.html#l01036">xnpod_set_thread_mode()</a>, and <a class="el" href="include_2nucleus_2thread_8h-source.html#l00048">XNRRB</a>.</p>

</div>
</div><p>
<a class="anchor" name="gfaebd1698caeb9b9b9e614ad84edd609"></a><!-- doxytag: member="sched.c::sched_get_priority_max" ref="gfaebd1698caeb9b9b9e614ad84edd609" args="(int policy)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int sched_get_priority_max           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>policy</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get maximum priority of the specified scheduling policy. 
<p>
This service returns the maximum priority of the scheduling policy <em>policy</em>.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>policy</em>&nbsp;</td><td>scheduling policy, one of SCHED_FIFO, SCHED_RR, or SCHED_OTHER.</td></tr>
  </table>
</dl>
<dl compact><dt><b>Return values:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>0</em>&nbsp;</td><td>on success; </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>-1</em>&nbsp;</td><td>with <em>errno</em> set if:<ul>
<li>EINVAL, <em>policy</em> is invalid.</li></ul>
</td></tr>
  </table>
</dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/sched_get_priority_max.html">Specification.</a> </dd></dl>

</div>
</div><p>
<a class="anchor" name="gf1f370fc36ea6b22ed42b5ee3cf82a81"></a><!-- doxytag: member="sched.c::sched_get_priority_min" ref="gf1f370fc36ea6b22ed42b5ee3cf82a81" args="(int policy)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int sched_get_priority_min           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>policy</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get minimum priority of the specified scheduling policy. 
<p>
This service returns the minimum priority of the scheduling policy <em>policy</em>.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>policy</em>&nbsp;</td><td>scheduling policy, one of SCHED_FIFO, SCHED_RR, or SCHED_OTHER.</td></tr>
  </table>
</dl>
<dl compact><dt><b>Return values:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>0</em>&nbsp;</td><td>on success; </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>-1</em>&nbsp;</td><td>with <em>errno</em> set if:<ul>
<li>EINVAL, <em>policy</em> is invalid.</li></ul>
</td></tr>
  </table>
</dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/sched_get_priority_min.html">Specification.</a> </dd></dl>

</div>
</div><p>
<a class="anchor" name="gf8bce87eeeae4d7e356b0a2d7ef09082"></a><!-- doxytag: member="sched.c::sched_rr_get_interval" ref="gf8bce87eeeae4d7e356b0a2d7ef09082" args="(int pid, struct timespec *interval)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int sched_rr_get_interval           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>pid</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct timespec *&nbsp;</td>
          <td class="paramname"> <em>interval</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Get the round-robin scheduling time slice. 
<p>
This service returns the time quantum used by Xenomai POSIX skin SCHED_RR scheduling policy.<p>
In kernel-space, this service only works if pid is zero, in user-space, round-robin scheduling policy is not supported, and this service not implemented.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>pid</em>&nbsp;</td><td>must be zero;</td></tr>
    <tr><td valign="top"></td><td valign="top"><em>interval</em>&nbsp;</td><td>address where the round-robin scheduling time quantum will be returned on success.</td></tr>
  </table>
</dl>
<dl compact><dt><b>Return values:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>0</em>&nbsp;</td><td>on success; </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>-1</em>&nbsp;</td><td>with <em>errno</em> set if:<ul>
<li>ESRCH, <em>pid</em> is invalid (not 0).</li></ul>
</td></tr>
  </table>
</dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/sched_rr_get_interval.html">Specification.</a> </dd></dl>

</div>
</div><p>
<a class="anchor" name="g357cd4b34c13011749dfffb42b489f09"></a><!-- doxytag: member="sched.c::sched_yield" ref="g357cd4b34c13011749dfffb42b489f09" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int sched_yield           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Yield the processor. 
<p>
This function move the current thread at the end of its priority group.<p>
<dl compact><dt><b>Return values:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>0</em>&nbsp;</td><td></td></tr>
  </table>
</dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/sched_yield.html">Specification.</a> </dd></dl>

</div>
</div><p>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Jun 8 18:08:52 2008 for Xenomai API by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address>
</body>
</html>