📄 xsh_chap02_08.html
字号:
<li><p>When the running thread with assigned priority equal to <i>sched_priority</i> becomes a blocked thread, the execution timeconsumed is subtracted from the available execution capacity, and a replenishment operation is scheduled, as described in 6 and 7.If the available execution capacity would become negative by this operation, it shall be set to zero.</p></li><li><p>When the running thread with assigned priority equal to <i>sched_priority</i> reaches the limit imposed on its execution time,it becomes the tail of the thread list for <i>sched_ss_low_priority</i>, the execution time consumed is subtracted from theavailable execution capacity (which becomes zero), and a replenishment operation is scheduled, as described in 6 and 7.</p></li><li><p>Each time a replenishment operation is scheduled, the amount of execution capacity to be replenished, <i>replenish_amount</i>,is set equal to the execution time consumed by the thread since the <i>activation_time</i>. The replenishment is scheduled to occurat <i>activation_time</i> plus <i>sched_ss_repl_period</i>. If the scheduled time obtained is before the current time, thereplenishment operation is carried out immediately. Several replenishment operations may be pending at the same time, each of whichwill be serviced at its respective scheduled time. With the above rules, the number of replenishment operations simultaneouslypending for a given thread that is scheduled under the sporadic server policy shall not be greater than<i>sched_ss_max_repl</i>.</p></li><li><p>A replenishment operation consists of adding the corresponding <i>replenish_amount</i> to the available execution capacity atthe scheduled time. If, as a consequence of this operation, the execution capacity would become larger than<i>sched_ss_initial_budget</i>, it shall be rounded down to a value equal to <i>sched_ss_initial_budget</i>. Additionally, if thethread was runnable or running, and had assigned priority equal to <i>sched_ss_low_priority</i>, then it becomes the tail of thethread list for <i>sched_priority</i>.</p></li></ol><p>Execution time is defined in <a href="xsh_chap02_02.html#tag_02_02_02"><i>The Name Space</i></a> .</p><p>For this policy, changing the value of a CPU-time clock via <a href="../functions/clock_settime.html"><i>clock_settime</i>()</a>shall have no effect on its behavior.</p><p>For this policy, valid priorities shall be within the range returned by the <a href="../functions/sched_get_priority_min.html"><i>sched_get_priority_min</i>()</a> and <a href="../functions/sched_get_priority_max.html"><i>sched_get_priority_max</i>()</a> functions when SCHED_SPORADIC is provided as theparameter. Conforming implementations shall provide a priority range of at least 32 distinct priorities for this policy.</p><h5><a name="tag_02_08_04_05"></a>SCHED_OTHER</h5><p>Conforming implementations shall include one scheduling policy identified as SCHED_OTHER (which may execute identically witheither the FIFO or round robin scheduling policy). The effect of scheduling threads with the SCHED_OTHER policy in a system inwhich other threads are executing under SCHED_FIFO, SCHED_RR, <sup>[<a href="javascript:open_code('SS')">SS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> or SCHED_SPORADIC <img src="../images/opt-end.gif" alt="[Option End]" border="0"> is implementation-defined.</p><p>This policy is defined to allow strictly conforming applications to be able to indicate in a portable manner that they no longerneed a realtime scheduling policy.</p><p>For threads executing under this policy, the implementation shall use only priorities within the range returned by the <a href="../functions/sched_get_priority_max.html"><i>sched_get_priority_max</i>()</a> and <a href="../functions/sched_get_priority_min.html"><i>sched_get_priority_min</i>()</a> functions when SCHED_OTHER is provided as theparameter.</p><h4><a name="tag_02_08_05"></a>Clocks and Timers</h4><p><sup>[<a href="javascript:open_code('TMR')">TMR</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The functionality described in this section is dependent on support of the Timers option (and the rest of this section is notfurther shaded for this option). <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>The <a href="../basedefs/time.h.html"><i><time.h></i></a> header defines the types and manifest constants used by thetiming facility.</p><h5><a name="tag_02_08_05_01"></a>Time Value Specification Structures</h5><p>Many of the timing facility functions accept or return time value specifications. A time value structure <b>timespec</b>specifies a single time value and includes at least the following members:</p><center><table border="1" cellpadding="3" align="center"><tr valign="top"><th align="center"><p class="tent"><b>Member Type</b></p></th><th align="center"><p class="tent"><b>Member Name</b></p></th><th align="center"><p class="tent"><b>Description</b></p></th></tr><tr valign="top"><td align="left"><p class="tent"><b>time_t</b></p></td><td align="left"><p class="tent"><i>tv_sec</i></p></td><td align="left"><p class="tent">Seconds.</p></td></tr><tr valign="top"><td align="left"><p class="tent"><b>long</b></p></td><td align="left"><p class="tent"><i>tv_nsec</i></p></td><td align="left"><p class="tent">Nanoseconds.</p></td></tr></table></center><p>The <i>tv_nsec</i> member is only valid if greater than or equal to zero, and less than the number of nanoseconds in a second(1000 million). The time interval described by this structure is (<i>tv_sec</i> * 10<sup><small>9</small></sup> + <i>tv_nsec</i>)nanoseconds.</p><p>A time value structure <b>itimerspec</b> specifies an initial timer value and a repetition interval for use by the per-processtimer functions. This structure includes at least the following members:</p><center><table border="1" cellpadding="3" align="center"><tr valign="top"><th align="center"><p class="tent"><b>Member Type</b></p></th><th align="center"><p class="tent"><b>Member Name</b></p></th><th align="center"><p class="tent"><b>Description</b></p></th></tr><tr valign="top"><td align="left"><p class="tent"><b>struct timespec</b></p></td><td align="left"><p class="tent"><i>it_interval</i></p></td><td align="left"><p class="tent">Timer period.</p></td></tr><tr valign="top"><td align="left"><p class="tent"><b>struct timespec</b></p></td><td align="left"><p class="tent"><i>it_value</i></p></td><td align="left"><p class="tent">Timer expiration.</p></td></tr></table></center><p>If the value described by <i>it_value</i> is non-zero, it indicates the time to or time of the next timer expiration (forrelative and absolute timer values, respectively). If the value described by <i>it_value</i> is zero, the timer shall bedisarmed.</p><p>If the value described by <i>it_interval</i> is non-zero, it specifies an interval which shall be used in reloading the timerwhen it expires; that is, a periodic timer is specified. If the value described by <i>it_interval</i> is zero, the timer isdisarmed after its next expiration; that is, a one-shot timer is specified.</p><h5><a name="tag_02_08_05_02"></a>Timer Event Notification Control Block</h5><p><sup>[<a href="javascript:open_code('RTS')">RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Per-process timers may be created that notify the process of timer expirations by queuing a realtime extended signal. The<b>sigevent</b> structure, defined in the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/signal.h.html"><i><signal.h></i></a>, is used in creating such a timer. The <b>sigevent</b> structure containsthe signal number and an application-specific data value which shall be used when notifying the calling process of timer expirationevents. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><h5><a name="tag_02_08_05_03"></a>Manifest Constants</h5><p>The following constants are defined in the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/time.h.html"><i><time.h></i></a>:</p><dl compact><dt>CLOCK_REALTIME</dt><dd>The identifier for the system-wide realtime clock.</dd><dt>TIMER_ABSTIME</dt><dd>Flag indicating time is absolute with respect to the clock associated with a timer.</dd><dt>CLOCK_MONOTONIC</dt><dd><sup>[<a href="javascript:open_code('MON')">MON</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The identifier for the system-wide monotonic clock, which is defined as a clock whose value cannot be set via <a href="../functions/clock_settime.html"><i>clock_settime</i>()</a> and which cannot have backward clock jumps. The maximum possible clockjump is implementation-defined. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl><p>The maximum allowable resolution for CLOCK_REALTIME and <sup>[<a href="javascript:open_code('MON')">MON</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> CLOCK_MONOTONIC <img src="../images/opt-end.gif" alt="[Option End]" border="0"> clocks and all time services based on these clocks is represented by {_POSIX_CLOCKRES_MIN} and shall bedefined as 20 ms (1/50 of a second). Implementations may support smaller values of resolution for these clocks to provide finergranularity time bases. The actual resolution supported by an implementation for a specific clock is obtained using the <a href="../functions/clock_getres.html"><i>clock_getres</i>()</a> function. If the actual resolution supported for a time service based onone of these clocks differs from the resolution supported for that clock, the implementation shall document this difference.</p><p>The minimum allowable maximum value for CLOCK_REALTIME and <sup>[<a href="javascript:open_code('MON')">MON</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> CLOCK_MONOTONIC <img src="../images/opt-end.gif" alt="[Option End]" border="0"> clocks and all absolute time services based on them is the same as that defined by the ISO Cstandard for the <b>time_t</b> type. If the maximum value supported by a time service based on one of these clocks differs from themaximum value supported by that clock, the implementation shall document this difference.</p><h5><a name="tag_02_08_05_04"></a>Execution Time Monitoring</h5><p><sup>[<a href="javascript:open_code('CPT')">CPT</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">If _POSIX_CPUTIME is defined, process CPU-time clocks shall be supported in addition to the clocks described in <a href="#tag_02_08_05_03">Manifest Constants</a> . <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p><sup>[<a href="javascript:open_code('TCT')">TCT</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">If _POSIX_THREAD_CPUTIME is defined, thread CPU-time clocks shall be supported. <img src="../images/opt-end.gif" alt="[Option End]"border="0"></p><p><sup>[<a href="javascript:open_code('CPT')">CPT|TCT</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> CPU-time clocks measure execution or CPU time, which is defined in the Base Definitions volume ofIEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap03.html#tag_03_117">Section 3.117, CPU Time (Execution Time)</a>. Themechanism used to measure execution time is described in the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap04.html#tag_04_09">Section 4.9, Measurement of Execution Time</a>. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p><sup>[<a href="javascript:open_code('CPT')">CPT</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">If _POSIX_CPUTIME is defined, the following constant of the type <b>clockid_t</b> is defined in <a href="../basedefs/time.h.html"><i><time.h></i></a>:</p><dl compact><dt>CLOCK_PROCESS_CPUTIME_ID</dt><dd><br>When this value of the type <b>clockid_t</b> is used in a <a href="../functions/clock.html"><i>clock</i>()</a> or <a href="../functions/timer_create.html"><i>timer*</i>()</a> function call, it is interpreted as the identifier of the CPU-time clock associatedwith the process making the function call.</dd></dl><img src="../images/opt-end.gif" alt="[Option End]" border="0"> <p><sup>[<a href="javascript:open_code('TCT')">TCT</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">If _POSIX_THREAD_CPUTIME is defined, the following constant of the type <b>clockid_t</b> is defined in <a href="../basedefs/time.h.html"><i><time.h></i></a>:</p><dl compact><dt>CLOCK_THREAD_CPUTIME_ID</dt><dd><br>When this value of the type <b>clockid_t</b> is used in a <a href="../functions/clock.html"><i>clock</i>()</a> or <a href="../functions/timer_create.html"><i>timer*</i>()</a> function call, it is interpreted as the identifier of the CPU-time clock associatedwith the thread making the function call. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl><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 + -