sched_setscheduler.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4. <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
  5. <TITLE>&quot;SCHED_SETSCHEDULER&quot;(P) manual page</TITLE>
  6. <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)">
  7. <META NAME="CREATED" CONTENT="20050505;13012200">
  8. <META NAME="CHANGED" CONTENT="20050505;13193700">
  9. <!-- manual page source format generated by PolyglotMan v3.2, -->
  10. <!-- available at http://polyglotman.sourceforge.net/ -->
  11. </HEAD>
  12. <BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR">
  13. <H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4>
  14. <P><A HREF="index.html">Reference Index</A></P>
  15. <P><A HREF="#toc">Table of Contents</A></P>
  16. <H2><A HREF="#toc0" NAME="sect0">Name</A></H2>
  17. <P>sched_setscheduler - set scheduling policy and parameters
  18. (<B>REALTIME</B>)
  19. </P>
  20. <H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2>
  21. <P><B>#include &lt;sched.h&gt; </B>
  22. </P>
  23. <P><B>int sched_setscheduler(pid_t</B> <I>pid</I><B>, int</B> <I>policy</I><B>,
  24. const struct sched_param *</B><I>param</I><B>); </B>
  25. </P>
  26. <H2><A HREF="#toc2" NAME="sect2">Description</A></H2>
  27. <P>The <B>sched_setscheduler</B> function shall set the scheduling
  28. policy and scheduling parameters of the process specified by <I>pid</I>
  29. to <I>policy</I> and the parameters specified in the <B>sched_param</B>
  30. structure pointed to by <I>param</I>, respectively. The value of the
  31. <I>sched_priority</I> member in the <B>sched_param</B> structure
  32. shall be any integer within the inclusive priority range for the
  33. scheduling policy specified by <I>policy</I>. If the value of <I>pid</I>
  34. is negative, the behavior of the <B>sched_setscheduler</B> function
  35. is unspecified.
  36. </P>
  37. <P>The possible values for the <I>policy</I> parameter are defined in
  38. the <I>&lt;sched.h&gt;</I> header.
  39. </P>
  40. <P><B>Pthreads-w32</B> only supports the <B>SCHED_OTHER</B> policy.
  41. Any other value for <I>policy</I> will return failure with errno set
  42. to <B>ENOSYS</B>. However, checks on <I>pid</I> and permissions are
  43. performed first so that the other useful side effects of this routine
  44. are retained.</P>
  45. <P>If a process specified by <I>pid</I> exists, and if the calling
  46. process has permission, the scheduling policy and scheduling
  47. parameters shall be set for the process whose process ID is equal to
  48. <I>pid</I>.
  49. </P>
  50. <P>If <I>pid</I> is zero, the scheduling policy and scheduling
  51. parameters shall be set for the calling process.
  52. </P>
  53. <P>Implementations may require that the requesting process have
  54. permission to set its own scheduling parameters or those of another
  55. process. Additionally, implementation-defined restrictions may apply
  56. as to the appropriate privileges required to set a process’ own
  57. scheduling policy, or another process’ scheduling policy, to a
  58. particular value.
  59. </P>
  60. <P>The <B>sched_setscheduler</B> function shall be considered
  61. successful if it succeeds in setting the scheduling policy and
  62. scheduling parameters of the process specified by <I>pid</I> to the
  63. values specified by <I>policy</I> and the structure pointed to by
  64. <I>param</I>, respectively.
  65. </P>
  66. <P>The effect of this function on individual threads is dependent on
  67. the scheduling contention scope of the threads:
  68. </P>
  69. <DL>
  70. <DT>*
  71. </DT><DD STYLE="margin-bottom: 0.5cm">
  72. For threads with system scheduling contention scope, these functions
  73. shall have no effect on their scheduling.
  74. </DD><DT>
  75. *
  76. </DT><DD STYLE="margin-bottom: 0.5cm">
  77. For threads with process scheduling contention scope, the threads’
  78. scheduling policy and associated parameters shall not be affected.
  79. However, the scheduling of these threads with respect to threads in
  80. other processes may be dependent on the scheduling parameters of
  81. their process, which are governed using these functions.
  82. </DD></DL>
  83. <P>
  84. This function is not atomic with respect to other threads in the
  85. process. Threads may continue to execute while this function call is
  86. in the process of changing the scheduling policy and associated
  87. scheduling parameters for the underlying kernel-scheduled entities
  88. used by the process contention scope threads.
  89. </P>
  90. <H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2>
  91. <P>Upon successful completion, the function shall return the former
  92. scheduling policy of the specified process. If the <B>sched_setscheduler</B>
  93. function fails to complete successfully, the policy and scheduling
  94. parameters shall remain unchanged, and the function shall return a
  95. value of -1 and set <I>errno</I> to indicate the error.
  96. </P>
  97. <H2><A HREF="#toc4" NAME="sect4">Errors</A></H2>
  98. <P>The <B>sched_setscheduler</B> function shall fail if:
  99. </P>
  100. <DL>
  101. <DT><B>EINVAL</B>
  102. </DT><DD>
  103. The value of the <I>policy</I> parameter is invalid, or one or more
  104. of the parameters contained in <I>param</I> is outside the valid
  105. range for the specified scheduling policy.
  106. </DD><DT>
  107. <B>EPERM</B>
  108. </DT><DD>
  109. The requesting process does not have permission to set either or
  110. both of the scheduling parameters or the scheduling policy of the
  111. specified process.
  112. </DD><DT>
  113. <B>ESRCH</B>
  114. </DT><DD STYLE="margin-bottom: 0.5cm">
  115. No process can be found corresponding to that specified by <I>pid</I>.
  116. </DD></DL>
  117. <P>
  118. <I>The following sections are informative.</I>
  119. </P>
  120. <H2><A HREF="#toc5" NAME="sect5">Examples</A></H2>
  121. <P>None.
  122. </P>
  123. <H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2>
  124. <P>None.
  125. </P>
  126. <H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2>
  127. <P>None.
  128. </P>
  129. <H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2>
  130. <P>None.
  131. </P>
  132. <H2><A HREF="#toc9" NAME="sect9">See Also</A></H2>
  133. <P><A HREF="sched_getscheduler.html"><B>sched_getscheduler</B>(3)</A>
  134. <B>,</B> the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001,
  135. <I>&lt;sched.h&gt;</I>
  136. </P>
  137. <H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2>
  138. <P>Portions of this text are reprinted and reproduced in electronic
  139. form from IEEE Std 1003.1, 2003 Edition, Standard for Information
  140. Technology -- Portable Operating System Interface (POSIX), The Open
  141. Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the
  142. Institute of Electrical and Electronics Engineers, Inc and The Open
  143. Group. In the event of any discrepancy between this version and the
  144. original IEEE and The Open Group Standard, the original IEEE and The
  145. Open Group Standard is the referee document. The original Standard
  146. can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A>
  147. .
  148. </P>
  149. <P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P>
  150. <HR>
  151. <P><A NAME="toc"></A><B>Table of Contents</B></P>
  152. <UL>
  153. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A>
  154. </P>
  155. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A>
  156. </P>
  157. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A>
  158. </P>
  159. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return
  160. Value</A>
  161. </P>
  162. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A>
  163. </P>
  164. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A>
  165. </P>
  166. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application
  167. Usage</A>
  168. </P>
  169. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A>
  170. </P>
  171. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future
  172. Directions</A>
  173. </P>
  174. <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See
  175. Also</A>
  176. </P>
  177. <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A>
  178. </P>
  179. </UL>
  180. </BODY>
  181. </HTML>