📄 sched_setscheduler.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>sched_setscheduler</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="sched_setscheduler"></a> <a name="tag_03_623"></a><!-- sched_setscheduler --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_623_01"></a>NAME</h4><blockquote>sched_setscheduler - set scheduling policy and parameters (<b>REALTIME</b>)</blockquote><h4><a name="tag_03_623_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('PS')">PS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> #include <<a href="../basedefs/sched.h.html">sched.h</a>><br><br> int sched_setscheduler(pid_t</tt> <i>pid</i><tt>, int</tt> <i>policy</i><tt>,<br> const struct sched_param *</tt><i>param</i><tt>); <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div><tt><br></tt></blockquote><h4><a name="tag_03_623_03"></a>DESCRIPTION</h4><blockquote><p>The <i>sched_setscheduler</i>() function shall set the scheduling policy and scheduling parameters of the process specified by<i>pid</i> to <i>policy</i> and the parameters specified in the <b>sched_param</b> structure pointed to by <i>param</i>,respectively. The value of the <i>sched_priority</i> member in the <b>sched_param</b> structure shall be any integer within theinclusive priority range for the scheduling policy specified by <i>policy</i>. If the value of <i>pid</i> is negative, the behaviorof the <i>sched_setscheduler</i>() function is unspecified.</p><p>The possible values for the <i>policy</i> parameter are defined in the <a href="../basedefs/sched.h.html"><i><sched.h></i></a> header.</p><p>If a process specified by <i>pid</i> exists, and if the calling process has permission, the scheduling policy and schedulingparameters shall be set for the process whose process ID is equal to <i>pid</i>.</p><p>If <i>pid</i> is zero, the scheduling policy and scheduling parameters shall be set for the calling process.</p><p>The conditions under which one process has the appropriate privilege to change the scheduling parameters of another process areimplementation-defined.</p><p>Implementations may require that the requesting process have permission to set its own scheduling parameters or those of anotherprocess. Additionally, implementation-defined restrictions may apply as to the appropriate privileges required to set a process'own scheduling policy, or another process' scheduling policy, to a particular value.</p><p>The <i>sched_setscheduler</i>() function shall be considered successful if it succeeds in setting the scheduling policy andscheduling parameters of the process specified by <i>pid</i> to the values specified by <i>policy</i> and the structure pointed toby <i>param</i>, respectively.</p><p><sup>[<a href="javascript:open_code('SS')">SS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Ifthe scheduling policy specified by <i>policy</i> is SCHED_SPORADIC, the value specified by the <i>sched_ss_low_priority</i> memberof the <i>param</i> argument shall be any integer within the inclusive priority range for the sporadic server policy. The<i>sched_ss_repl_period</i> and <i>sched_ss_init_budget</i> members of the <i>param</i> argument shall represent the timeparameters used by the sporadic server scheduling policy for the target process. The <i>sched_ss_max_repl</i> member of the<i>param</i> argument shall represent the maximum number of replenishments that are allowed to be pending simultaneously for theprocess scheduled under this scheduling policy.</p><p>The specified <i>sched_ss_repl_period</i> shall be greater than or equal to the specified <i>sched_ss_init_budget</i> for thefunction to succeed; if it is not, then the function shall fail.</p><p>The value of <i>sched_ss_max_repl</i> shall be within the inclusive range [1, {SS_REPL_MAX}] for the function to succeed; ifnot, the function shall fail.</p><p>If the scheduling policy specified by <i>policy</i> is either SCHED_FIFO or SCHED_RR, the <i>sched_ss_low_priority</i>,<i>sched_ss_repl_period</i>, and <i>sched_ss_init_budget</i> members of the <i>param</i> argument shall have no effect on thescheduling behavior. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>The effect of this function on individual threads is dependent on the scheduling contention scope of the threads:</p><ul><li><p>For threads with system scheduling contention scope, these functions shall have no effect on their scheduling.</p></li><li><p>For threads with process scheduling contention scope, the threads' scheduling policy and associated parameters shall not beaffected. However, the scheduling of these threads with respect to threads in other processes may be dependent on the schedulingparameters of their process, which are governed using these functions.</p></li></ul><p>If an implementation supports a two-level scheduling model in which library threads are multiplexed on top of severalkernel-scheduled entities, then the underlying kernel-scheduled entities for the system contention scope threads shall not beaffected by these functions.</p><p>The underlying kernel-scheduled entities for the process contention scope threads shall have their scheduling policy andassociated scheduling parameters changed to the values specified in <i>policy</i> and <i>param</i>, respectively. Kernel-scheduledentities for use by process contention scope threads that are created after this call completes shall inherit their schedulingpolicy and associated scheduling parameters from the process.</p><p>This function is not atomic with respect to other threads in the process. Threads may continue to execute while this functioncall is in the process of changing the scheduling policy and associated scheduling parameters for the underlying kernel-scheduledentities used by the process contention scope threads.</p></blockquote><h4><a name="tag_03_623_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, the function shall return the former scheduling policy of the specified process. If the<i>sched_setscheduler</i>() function fails to complete successfully, the policy and scheduling parameters shall remain unchanged,and the function shall return a value of -1 and set <i>errno</i> to indicate the error.</p></blockquote><h4><a name="tag_03_623_05"></a>ERRORS</h4><blockquote><p>The <i>sched_setscheduler</i>() function shall fail if:</p><dl compact><dt>[EINVAL]</dt><dd>The value of the <i>policy</i> parameter is invalid, or one or more of the parameters contained in <i>param</i> is outside thevalid range for the specified scheduling policy.</dd><dt>[EPERM]</dt><dd>The requesting process does not have permission to set either or both of the scheduling parameters or the scheduling policy ofthe specified process.</dd><dt>[ESRCH]</dt><dd>No process can be found corresponding to that specified by <i>pid</i>.</dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_623_06"></a>EXAMPLES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_623_07"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_623_08"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_623_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_623_10"></a>SEE ALSO</h4><blockquote><p><a href="sched_getparam.html"><i>sched_getparam</i>()</a> , <a href="sched_getscheduler.html"><i>sched_getscheduler</i>()</a> ,<a href="sched_setparam.html"><i>sched_setparam</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/sched.h.html"><i><sched.h></i></a></p></blockquote><h4><a name="tag_03_623_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 5. Included for alignment with the POSIX Realtime Extension.</p></blockquote><h4><a name="tag_03_623_12"></a>Issue 6</h4><blockquote><p>The <i>sched_setscheduler</i>() function is marked as part of the Process Scheduling option.</p><p>The [ENOSYS] error condition has been removed as stubs need not be provided if an implementation does not support the ProcessScheduling option.</p><p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p><ul><li><p>In the DESCRIPTION, the effect of this function on a thread's scheduling parameters is added.</p></li><li><p>Sections describing two-level scheduling and atomicity of the function are added.</p></li></ul><p>The SCHED_SPORADIC scheduling policy is added for alignment with IEEE Std 1003.1d-1999.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX ® is a registered Trademark of The Open Group.<br>POSIX ® is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -