sched_setscheduler.2 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. .\" Copyright (c) 1998 HD Associates, Inc.
  2. .\" All rights reserved.
  3. .\"
  4. .\" Redistribution and use in source and binary forms, with or without
  5. .\" modification, are permitted provided that the following conditions
  6. .\" are met:
  7. .\" 1. Redistributions of source code must retain the above copyright
  8. .\" notice, this list of conditions and the following disclaimer.
  9. .\" 2. Redistributions in binary form must reproduce the above copyright
  10. .\" notice, this list of conditions and the following disclaimer in the
  11. .\" documentation and/or other materials provided with the distribution.
  12. .\"
  13. .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  14. .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  16. .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  17. .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18. .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  19. .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  20. .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  21. .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  22. .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. .\" SUCH DAMAGE.
  24. .\"
  25. .Dd March 12, 1998
  26. .Dt SCHED_SETSCHEDULER 2
  27. .Os
  28. .Sh NAME
  29. .Nm sched_setscheduler ,
  30. .Nm sched_getscheduler
  31. .Nd set/get scheduling policy and scheduler parameters
  32. .Sh LIBRARY
  33. .Lb libc
  34. .Sh SYNOPSIS
  35. .In sched.h
  36. .Ft int
  37. .Fn sched_setscheduler "pid_t pid" "int policy" "const struct sched_param *param"
  38. .Ft int
  39. .Fn sched_getscheduler "pid_t pid"
  40. .Sh DESCRIPTION
  41. The
  42. .Fn sched_setscheduler
  43. system call sets the scheduling policy and scheduling parameters
  44. of the process specified by
  45. .Fa pid
  46. to
  47. .Fa policy
  48. and the parameters specified in the
  49. .Vt sched_param
  50. structure pointed to by
  51. .Fa param ,
  52. respectively.
  53. The value of the
  54. .Fa sched_priority
  55. member in the
  56. .Fa param
  57. structure must be any integer within the inclusive priority range for
  58. the scheduling policy specified by
  59. .Fa policy .
  60. .Pp
  61. In this implementation, if the value of
  62. .Fa pid
  63. is negative the system call will fail.
  64. .Pp
  65. If a process specified by
  66. .Fa pid
  67. exists and if the calling process has permission, the scheduling
  68. policy and scheduling parameters will be set for the process
  69. whose process ID is equal to
  70. .Fa pid .
  71. .Pp
  72. If
  73. .Fa pid
  74. is zero, the scheduling policy and scheduling
  75. parameters are set for the calling process.
  76. .Pp
  77. In this implementation, the policy of when a process can affect
  78. the scheduling parameters of another process is specified in
  79. .St -p1003.1b-93
  80. as a write-style operation.
  81. .Pp
  82. The scheduling policies are in
  83. .Fa <sched.h> :
  84. .Bl -tag -width [SCHED_OTHER]
  85. .It Bq Er SCHED_FIFO
  86. First-in-first-out fixed priority scheduling with no round robin scheduling;
  87. .It Bq Er SCHED_OTHER
  88. The standard time sharing scheduler;
  89. .It Bq Er SCHED_RR
  90. Round-robin scheduling across same priority processes.
  91. .El
  92. .Pp
  93. The
  94. .Vt sched_param
  95. structure is defined in
  96. .Fa <sched.h> :
  97. .Bd -literal -offset indent
  98. struct sched_param {
  99. int sched_priority; /* scheduling priority */
  100. };
  101. .Ed
  102. .Pp
  103. The
  104. .Fn sched_getscheduler
  105. system call returns the scheduling policy of the process specified
  106. by
  107. .Fa pid .
  108. .Pp
  109. If a process specified by
  110. .Fa pid
  111. exists and if the calling process has permission,
  112. the scheduling parameters for the process whose process ID is equal to
  113. .Fa pid
  114. are returned.
  115. .Pp
  116. In this implementation, the policy of when a process can obtain the
  117. scheduling parameters of another process are detailed in
  118. .St -p1003.1b-93
  119. as a read-style operation.
  120. .Pp
  121. If
  122. .Fa pid
  123. is zero, the scheduling parameters for the calling process will be
  124. returned.
  125. In this implementation, the
  126. .Fa sched_getscheduler
  127. system call will fail if
  128. .Fa pid
  129. is negative.
  130. .Sh RETURN VALUES
  131. .Rv -std
  132. .Sh ERRORS
  133. On failure
  134. .Va errno
  135. will be set to the corresponding value:
  136. .Bl -tag -width Er
  137. .It Bq Er ENOSYS
  138. The system is not configured to support this functionality.
  139. .It Bq Er EPERM
  140. The requesting process doesn not have permission as detailed in
  141. .St -p1003.1b-93 .
  142. .It Bq Er ESRCH
  143. No process can be found corresponding to that specified by
  144. .Fa pid .
  145. .It Bq Er EINVAL
  146. The value of the
  147. .Fa policy
  148. argument is invalid, or one or more of the parameters contained in
  149. .Fa param
  150. is outside the valid range for the specified scheduling policy.
  151. .El
  152. .Sh SEE ALSO
  153. .Xr sched_get_priority_max 2 ,
  154. .Xr sched_get_priority_min 2 ,
  155. .Xr sched_getparam 2 ,
  156. .Xr sched_rr_get_interval 2 ,
  157. .Xr sched_setparam 2 ,
  158. .Xr sched_yield 2
  159. .Sh STANDARDS
  160. The
  161. .Fn sched_setscheduler
  162. and
  163. .Fn sched_getscheduler
  164. system calls conform to
  165. .St -p1003.1b-93 .