⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 realtime.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
structure is used as ahandle for retrieving the error status and return statusof the asynchronous operation while it is in progress.<p>The<b>aiocb</b>structure and the data buffersassociated with the asynchronous I/O operation are being usedby the system for asynchronous I/O while, and only while,the error status of the asynchronous operationis equal to EINPROGRESS.Applications must not modify the<b>aiocb</b>structure while the structure is being used by the system forasynchronous I/O.<p>The return status of the asynchronous operationis the number of bytes transferred by the I/O operation.If the error status is set to indicate an error completion,then the return status is set to the return value that thecorresponding<i><a href="read.html">read()</a></i>,<i><a href="write.html">write()</a></i>,or<i><a href="fsync.html">fsync()</a></i>call would have returned.When the error status is not equal to EINPROGRESS,the return statusreflects the return status of the corresponding synchronous operation.<h4><a name = "tag_000_008_003">&nbsp;</a>Memory Management</h4>Range memory locking and memory mapping operations are defined interms of pages.Implementations may restrict the size and alignmentof range lockings and mappings to be onpage-size boundaries.The page size, in bytes, is the value of the configurable systemvariable {PAGESIZE}.If an implementation has no restrictions on size or alignment,it may specify a 1 byte page size.<p>Memory locking guarantees the residence of portions of the addressspace.  It is implementation-dependentwhether locking memory guarantees fixed translation between virtualaddresses (as seen by the process) and physical addresses.Per-process memory locks are not inherited across a<i><a href="fork.html">fork()</a></i>,and all memory locks owned by a process are unlocked upon<i>exec</i>or process termination.Unmapping of an address range removes any memory locksestablished on that address range by this process.<p>Memory Mapped Files provide a mechanism that allows aprocess to access filesby directly incorporating file data into its address space.Once a file is mapped into a process address space,the data can be manipulated as memory.If more than one process maps a file, its contents are shared among them.If the mappings allow shared write accessthen data written into the memory objectthrough the address space of one process appearsin the address spaces of all processesthat similarly map the same portion of the memory object.<p>Shared memory objects are named regions of storagethat may be independent of the file system and can be mapped intothe address space of one or more processes to allow them to share theassociated memory.<p>An<i><a href="unlink.html">unlink()</a></i>of a fileor<i><a href="shm_unlink.html">shm_unlink()</a></i>of a shared memory object,while causing the removal of the name,does not unmap any mappings established for the object.Once the name has been removed,the contents of the memory object are preserved as long as it isreferenced.The memory object remains referencedas long as a process has the memory object openor has some area of the memory object mapped.<p>Mapping may be restricted to disallow some types of access.References to whole pages within the mappingbut beyond the current length of an object result in aSIGBUS signal.SIGBUS is used in this context to indicate an error using the object.The size of the object is unaffected by access beyond the end of theobject.Write attempts to memory that was mapped without write access,or any access to memory mapped PROT_NONE,results in a SIGSEGV signal.SIGSEGV is used in this context to indicate a mapping error.References to unmapped addresses result in a SIGSEGV signal.<h4><a name = "tag_000_008_004">&nbsp;</a>Scheduling Policies</h4><p>The scheduling semantics described in this specification are definedin terms of a conceptual model that contains a set of thread lists.No implementation structures are necessarily impliedby the use of this conceptual model.It is assumed that no time elapses during operationsdescribed using this model,and therefore no simultaneous operations are possible.This model discusses only processor scheduling for runnable threads,but it should be noted that greatly enhanced predictabilityof realtime applications will resultif the sequencing of other resources takesprocessor scheduling policy into account.<p>There is, conceptually, one thread list for each priority.Any runnable thread may be on any thread list.Multiple scheduling policies are provided.Each non-empty thread list is ordered,contains a head as one end of its order, and a tail as the other.The purpose of a scheduling policy is to define the allowable operationson this set of lists(for example, moving threads between and within lists).<p>Each process is controlledby an associated scheduling policy and priority.These parameters may be specified by explicit application execution of the<i><a href="sched_setscheduler.html">sched_setscheduler()</a></i>or<i><a href="sched_setparam.html">sched_setparam()</a></i>functions.<p>Each thread is controlled by an associated scheduling policy andpriority.  These parameters may be specified by explicit applicationexecution of the<i><a href="pthread_setschedparam.html">pthread_setschedparam()</a></i>function.<p>Associated with each policy is a priority range.Each policy definition specifiesthe minimum priority range for that policy.The priority ranges for each policy may or may not overlap the priority rangesof other policies.<p>A conforming implementation selects the thread that is defined asbeing at the head of the highest priority non-empty thread listto become a running thread, regardless of its associated policy.This thread is then removed from its thread list.<p>Three scheduling policies are specifically required.Other implementation-dependent scheduling policies may be defined.The following symbols are defined in the header<i><a href="sched.h.html">&lt;sched.h&gt;</a></i>:<div><p><table  bordercolor=#000000 border=1 align=center><tr valign=top><th align=center><b>Symbol</b><th align=center><b>Description</b><tr valign=top><td align=left>SCHED_FIFO<td align=left>First in-first out (FIFO) scheduling policy.<tr valign=top><td align=left>SCHED_RR<td align=left>Round robin scheduling policy.<tr valign=top><td align=left>SCHED_OTHER<td align=left>Another scheduling policy.</table></div><p>The values of these symbols will be distinct.<h5><a name = "tag_000_008_004_001">&nbsp;</a>SCHED_FIFO</h5>Conforming implementations include a scheduling policycalled the FIFO scheduling policy.<p>Threads scheduled under this policy are chosen from athread list that is ordered by the timeits threads have been on the list without being executed;generally, the head of the list isthe thread that has been on the list the longest time,and the tail is thethread that has been on the list the shortest time.<p>Under the SCHED_FIFOpolicy, the modification of the definitional thread lists is as follows:<ol type = 1><p><li>When a running thread becomes a preempted thread, it becomes the headof the thread list for its priority.<p><li>When a blocked thread becomes a runnable thread, it becomes the tailof the thread list for its priority.<p><li>When a running thread calls the<i><a href="sched_setscheduler.html">sched_setscheduler()</a></i>function,the process specified in the function call is modified to the specified policyand the priority specified by the<i>param</i>argument.<p><li>When a running thread calls the<i><a href="sched_setparam.html">sched_setparam()</a></i>function, the priority of the process specified in the function callis modified to the priority specified by the<i>param</i>argument.<p><li>When a running thread calls the<i><a href="pthread_setschedparam.html">pthread_setschedparam()</a></i>function, the thread specified in the function call is modified to thespecified policy and the priority specified by the<i>param</i>argument.<p><li>If a thread whose policy or priority has been modified is a runningthread or is runnable, it then becomes the tail of the thread list forits new priority.<p><li>When a running thread issues the<i><a href="sched_yield.html">sched_yield()</a></i>function,the thread becomes the tail of the thread list for its priority.<p><li>At no other time will the position of a thread with this scheduling policywithin the thread lists be affected.<p></ol><p>For this policy, valid priorities shall be within the range returned by thefunction<i><a href="sched_get_priority_max.html">sched_get_priority_max()</a></i>and<i><a href="sched_get_priority_min.html">sched_get_priority_min()</a></i>when SCHED_FIFOis provided as the parameter.Conforming implementations provide a priority range of at least 32priorities for this policy.<h5><a name = "tag_000_008_004_002">&nbsp;</a>SCHED_RR</h5><p>Conforming implementations include a scheduling policy called theround robin scheduling policy.This policy is identical to the SCHED_FIFOpolicy with the additional condition that when the implementation detects thata running thread has been executing as a running threadfor a time period of the length returned by the function<i><a href="sched_rr_get_interval.html">sched_rr_get_interval()</a></i>or longer,the thread becomes the tail of its thread listand the head of that thread list is removed and made a running thread.<p>The effect of this policy is to ensure that if there aremultiple SCHED_RR threads at the same priority,one of them will not monopolise the processor.An application should not rely only on the use ofSCHED_RR to ensure application progress among multiple threadsif the application includes threads using theSCHED_FIFO policy at the same or higher priority levels orSCHED_RR threads at a higher priority level.<p>A thread under this policy that is preempted and subsequently resumesexecution as a running threadcompletes the unexpired portion of its round-robin-interval time period.<p>For this policy, valid priorities will be within the rangereturned by the functions<i><a href="sched_get_priority_max.html">sched_get_priority_max()</a></i>and<i><a href="sched_get_priority_min.html">sched_get_priority_min()</a></i>when SCHED_RR is provided as the parameter.Conforming implementations will provide a priority range of at least 32priorities for this policy.<h5><a name = "tag_000_008_004_003">&nbsp;</a>SCHED_OTHER</h5><p>Conforming implementations includeone scheduling policy identified as SCHED_OTHER(which may execute identically with either the FIFOor round robin scheduling policy).The effect of scheduling threads with theSCHED_OTHER policy in a system in which other threadsare executing under SCHED_FIFO or SCHED_RRis implementation-dependent.<p>This policy is defined to allow conforming applications to be ableto indicate that they no longer need a realtime scheduling policyin a portable manner.<p>For threads executing under this policy,the implementation uses only priorities within the range returned by thefunctions<i><a href="sched_get_priority_max.html">sched_get_priority_max()</a></i>and<i><a href="sched_get_priority_min.html">sched_get_priority_min()</a></i>when SCHED_OTHERis provided as the parameter.<h4><a name = "tag_000_008_005">&nbsp;</a>Clocks and Timers</h4>The header file<i><a href="time.h.html">&lt;time.h&gt;</a></i>defines the types and manifest constants used by the timing facility.<h5><a name = "tag_000_008_005_001">&nbsp;</a>Time Value Specification Structures</h5><p>Many of the timing facility functions accept or return time valuespecifications.A time value structure<b>timespec</b>specifies a single time value and includes at least the following members:<p><table  bordercolor=#000000 border=1 align=center><tr valign=top><th align=center><b>Member Type</b><th align=center><b>Member Name</b><th align=center><b>Description</b><tr valign=top><td align=left>time_t<td align=left>tv_sec<td align=left>Seconds<tr valign=top><td align=left>long<td align=left>tv_nsec<td align=left>Nanoseconds</table><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'-.4m'<small>9</small>'.4m' + <i>tv_nsec</i>)nanoseconds.<p>A time value structure<b>itimerspec</b>specifies an initial timer value and a repetition intervalfor use by the per-process timer functions.This structure includes at least the following members:<p><table  bordercolor=#000000 border=1 align=center><tr valign=top><th align=center><b>Member Type</b><th align=center><b>Member Name</b><th align=center><b>Description</b><tr valign=top><td align=left>struct timespec<td align=left>it_interval<td align=left>Timer period<tr valign=top><td align=left>struct timespec<td align=left>it_value<td align=left>Timer expiration</table><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(for relative and absolute timer values, respectively).If the value described by<i>it_value</i>is zero, the timer is disarmed.<p>If the value described by<i>it_interval</i>is non-zero, it specifies an interval to 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 will be disarmed after its next expiration; that is, aone-shot timer is specified.<h5><a name = "tag_000_008_005_002">&nbsp;</a>Timer Event Notification Control Block</h5><p>Per-process timers may be created that notify the processof timer expirations by queuing a realtime extended signal.The<b>sigevent</b>structure, defined in<i><a href="signal.h.html">&lt;signal.h&gt;</a></i>,is used in creating such a timer.The<b>sigevent</b>structure contains the signal number and an application-specific data valueto be used when notifyingthe calling process of timer expiration events.<h5><a name = "tag_000_008_005_003">&nbsp;</a>Manifest Constants</h5><p>The following constants are defined in<i><a href="time.h.html">&lt;time.h&gt;</a></i>:<dl compact><dt>CLOCK_REALTIME<dd>The identifier for the systemwide realtime clock.<dt>TIMER_ABSTIME<dd>Flag indicating time is absolutewith respect to the clock associated with a timer.</dl><p>The maximum allowable resolution for the CLOCK_REALTIMEclock and all timers based on this clock, including the<i><a href="nanosleep.html">nanosleep()</a></i>function, is represented by {_POSIX_CLOCKRES_MIN}and is defined as 20 ms (1/50 of a second).Implementations may support smaller values of resolution for theCLOCK_REALTIME clock to provide finer granularity time bases.<p>The minimum allowable maximum value for the CLOCK_REALTIMEclock and absolute timers based on itis the same as that defined by the ISO C standard for the<i>time_t</i>type.</blockquote><hr size=2 noshade><center><font size=2>UNIX &reg; is a registered Trademark of The Open Group.<br>Copyright &copy; 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -