📄 xsh_chap02_08.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>System Interfaces Chapter 2</title></head><body><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1-2001</font></center><hr size="2" noshade><h3><a name="tag_02_08"></a>Realtime</h3><p>This section defines functions to support the source portability of applications with realtime requirements. The presence ofmany of these functions is dependent on support for implementation options described in the text.</p><p>The specific functional areas included in this section and their scope include the following. Full definitions of these termscan be found in the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap03.html">Chapter 3,Definitions</a>.</p><ul><li><p>Semaphores</p></li><li><p>Process Memory Locking</p></li><li><p>Memory Mapped Files and Shared Memory Objects</p></li><li><p>Priority Scheduling</p></li><li><p>Realtime Signal Extension</p></li><li><p>Timers</p></li><li><p>Interprocess Communication</p></li><li><p>Synchronized Input and Output</p></li><li><p>Asynchronous Input and Output</p></li></ul><p>All the realtime functions defined in this volume of IEEE Std 1003.1-2001 are portable, although some of the numericparameters used by an implementation may have hardware dependencies.</p><h4><a name="tag_02_08_01"></a>Realtime Signals</h4><p><sup>[<a href="javascript:open_code('RTS')">RTS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Realtime signal generation and delivery is dependent on support for the Realtime Signals Extension option. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>See <a href="xsh_chap02_04.html#tag_02_04_02"><i>Realtime Signal Generation and Delivery</i></a> .</p><h4><a name="tag_02_08_02"></a>Asynchronous I/O</h4><p><sup>[<a href="javascript:open_code('AIO')">AIO</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 Asynchronous Input and Output option (and the rest ofthis section is not further marked for this option). <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>An asynchronous I/O control block structure <b>aiocb</b> is used in many asynchronous I/O functions. It is defined in the BaseDefinitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/aio.h.html"><i><aio.h></i></a> and has at leastthe 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>int</b></p></td><td align="left"><p class="tent"><i>aio_fildes</i></p></td><td align="left"><p class="tent">File descriptor.</p></td></tr><tr valign="top"><td align="left"><p class="tent"><b>off_t</b></p></td><td align="left"><p class="tent"><i>aio_offset</i></p></td><td align="left"><p class="tent">File offset.</p></td></tr><tr valign="top"><td align="left"><p class="tent"><b>volatile void*</b></p></td><td align="left"><p class="tent"><i>aio_buf</i></p></td><td align="left"><p class="tent">Location of buffer.</p></td></tr><tr valign="top"><td align="left"><p class="tent"><b>size_t</b></p></td><td align="left"><p class="tent"><i>aio_nbytes</i></p></td><td align="left"><p class="tent">Length of transfer.</p></td></tr><tr valign="top"><td align="left"><p class="tent"><b>int</b></p></td><td align="left"><p class="tent"><i>aio_reqprio</i></p></td><td align="left"><p class="tent">Request priority offset.</p></td></tr><tr valign="top"><td align="left"><p class="tent"><b>struct sigevent</b></p></td><td align="left"><p class="tent"><i>aio_sigevent</i></p></td><td align="left"><p class="tent">Signal number and value.</p></td></tr><tr valign="top"><td align="left"><p class="tent"><b>int</b></p></td><td align="left"><p class="tent"><i>aio_lio_opcode</i></p></td><td align="left"><p class="tent">Operation to be performed.</p></td></tr></table></center><p>The <i>aio_fildes</i> element is the file descriptor on which the asynchronous operation is performed.</p><p>If O_APPEND is not set for the file descriptor <i>aio_fildes</i> and if <i>aio_fildes</i> is associated with a device that iscapable of seeking, then the requested operation takes place at the absolute position in the file as given by <i>aio_offset</i>, asif <a href="../functions/lseek.html"><i>lseek</i>()</a> were called immediately prior to the operation with an <i>offset</i>argument equal to <i>aio_offset</i> and a <i>whence</i> argument equal to SEEK_SET. If O_APPEND is set for the file descriptor, orif <i>aio_fildes</i> is associated with a device that is incapable of seeking, write operations append to the file in the sameorder as the calls were made, with the following exception: under implementation-defined circumstances, such as operation on amulti-processor or when requests of differing priorities are submitted at the same time, the ordering restriction may be relaxed.Since there is no way for a strictly conforming application to determine whether this relaxation applies, all strictly conformingapplications which rely on ordering of output shall be written in such a way that they will operate correctly if the relaxationapplies. After a successful call to enqueue an asynchronous I/O operation, the value of the file offset for the file isunspecified. The <i>aio_nbytes</i> and <i>aio_buf</i> elements are the same as the <i>nbyte</i> and <i>buf</i> arguments defined by<a href="../functions/read.html"><i>read</i>()</a> and <a href="../functions/write.html"><i>write</i>()</a>, respectively.</p><p>If _POSIX_PRIORITIZED_IO and _POSIX_PRIORITY_SCHEDULING are defined, then asynchronous I/O is queued in priority order, with thepriority of each asynchronous operation based on the current scheduling priority of the calling process. The <i>aio_reqprio</i>member can be used to lower (but not raise) the asynchronous I/O operation priority and is within the range zero through{AIO_PRIO_DELTA_MAX}, inclusive. Unless both _POSIX_PRIORITIZED_IO and _POSIX_PRIORITY_SCHEDULING are defined, the order ofprocessing asynchronous I/O requests is unspecified. When both _POSIX_PRIORITIZED_IO and _POSIX_PRIORITY_SCHEDULING are defined,the order of processing of requests submitted by processes whose schedulers are not SCHED_FIFO, SCHED_RR, or SCHED_SPORADIC isunspecified. The priority of an asynchronous request is computed as (process scheduling priority) minus <i>aio_reqprio</i>. Thepriority assigned to each asynchronous I/O request is an indication of the desired order of execution of the request relative toother asynchronous I/O requests for this file. If _POSIX_PRIORITIZED_IO is defined, requests issued with the same priority to acharacter special file are processed by the underlying device in FIFO order; the order of processing of requests of the samepriority issued to files that are not character special files is unspecified. Numerically higher priority values indicate requestsof higher priority. The value of <i>aio_reqprio</i> has no effect on process scheduling priority. When prioritized asynchronous I/Orequests to the same file are blocked waiting for a resource required for that I/O operation, the higher-priority I/O requestsshall be granted the resource before lower-priority I/O requests are granted the resource. The relative priority of asynchronousI/O and synchronous I/O is implementation-defined. If _POSIX_PRIORITIZED_IO is defined, the implementation shall define for whichfiles I/O prioritization is supported.</p><p>The <i>aio_sigevent</i> determines how the calling process shall be notified upon I/O completion, as specified in <a href="xsh_chap02_04.html#tag_02_04_01"><i>Signal Generation and Delivery</i></a> . If <i>aio_sigevent.sigev_notify</i> is SIGEV_NONE,then no signal shall be posted upon I/O completion, but the error status for the operation and the return status for the operationshall be set appropriately.</p><p>The <i>aio_lio_opcode</i> field is used only by the <a href="../functions/lio_listio.html"><i>lio_listio</i>()</a> call. The <ahref="../functions/lio_listio.html"><i>lio_listio</i>()</a> call allows multiple asynchronous I/O operations to be submitted at asingle time. The function takes as an argument an array of pointers to <b>aiocb</b> structures. Each <b>aiocb</b> structureindicates the operation to be performed (read or write) via the <i>aio_lio_opcode</i> field.</p><p>The address of the <b>aiocb</b> structure is used as a handle for retrieving the error status and return status of theasynchronous operation while it is in progress.</p><p>The <b>aiocb</b> structure and the data buffers associated with the asynchronous I/O operation are being used by the system forasynchronous I/O while, and only while, the error status of the asynchronous operation is equal to [EINPROGRESS]. Applicationsshall not modify the <b>aiocb</b> structure while the structure is being used by the system for asynchronous I/O.</p><p>The return status of the asynchronous operation is the number of bytes transferred by the I/O operation. If the error status isset to indicate an error completion, then the return status is set to the return value that the corresponding <a href="../functions/read.html"><i>read</i>()</a>, <a href="../functions/write.html"><i>write</i>()</a>, or <a href="../functions/fsync.html"><i>fsync</i>()</a> call would have returned. When the error status is not equal to [EINPROGRESS], thereturn status shall reflect the return status of the corresponding synchronous operation.</p><h4><a name="tag_02_08_03"></a>Memory Management</h4><h5><a name="tag_02_08_03_01"></a>Memory Locking</h5><p><sup>[<a href="javascript:open_code('MR')">MR</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Range memory locking operations are defined in terms of pages. Implementations may restrict the size and alignment of rangelockings to be on page-size boundaries. The page size, in bytes, is the value of the configurable system variable {PAGESIZE}. If animplementation has no restrictions on size or alignment, it may specify a 1-byte page size. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p><sup>[<a href="javascript:open_code('ML')">ML|MLR</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Memory locking guarantees the residence of portions of the address space. It is implementation-defined whether locking memoryguarantees fixed translation between virtual addresses (as seen by the process) and physical addresses. Per-process memory locksare not inherited across a <a href="../functions/fork.html"><i>fork</i>()</a>, and all memory locks owned by a process are unlockedupon <i><a href="../functions/exec.html">exec</a></i> or process termination. Unmapping of an address range removes any memorylocks established on that address range by this process. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><h5><a name="tag_02_08_03_02"></a>Memory Mapped Files</h5><p><sup>[<a href="javascript:open_code('MF')">MF</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Thefunctionality described in this section is dependent on support of the Memory Mapped Files option (and the rest of this section isnot further marked for this option). <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>Range memory mapping operations are defined in terms of pages. Implementations may restrict the size and alignment of rangemappings to be on page-size boundaries. The page size, in bytes, is the value of the configurable system variable {PAGESIZE}. If animplementation has no restrictions on size or alignment, it may specify a 1-byte page size.</p><p>Memory mapped files provide a mechanism that allows a process to access files by directly incorporating file data into itsaddress space. Once a file is mapped into a process address space, the data can be manipulated as memory. If more than one process
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -