📄 xbd_chap04.html
字号:
<p>Unless explicitly stated otherwise, if one of the above functions returns an error, it is unspecified whether the invocationcauses memory to be synchronized.</p><p>Applications may allow more than one thread of control to read a memory location simultaneously.</p><h3><a name="tag_04_11"></a>Pathname Resolution</h3><p>Pathname resolution is performed for a process to resolve a pathname to a particular file in a file hierarchy. There may bemultiple pathnames that resolve to the same file.</p><p>Each filename in the pathname is located in the directory specified by its predecessor (for example, in the pathname fragment<b>a/b</b>, file <b>b</b> is located in directory <b>a</b>). Pathname resolution shall fail if this cannot be accomplished. If thepathname begins with a slash, the predecessor of the first filename in the pathname shall be taken to be the root directory of theprocess (such pathnames are referred to as "absolute pathnames"). If the pathname does not begin with a slash, the predecessor ofthe first filename of the pathname shall be taken to be the current working directory of the process (such pathnames are referredto as "relative pathnames").</p><p>The interpretation of a pathname component is dependent on the value of {NAME_MAX} and _POSIX_NO_TRUNC associated with the pathprefix of that component. If any pathname component is longer than {NAME_MAX}, the implementation shall consider this an error.</p><p>A pathname that contains at least one non-slash character and that ends with one or more trailing slashes shall be resolved asif a single dot character ( <tt>'.'</tt> ) were appended to the pathname.</p><p>If a symbolic link is encountered during pathname resolution, the behavior shall depend on whether the pathname component is atthe end of the pathname and on the function being performed. If all of the following are true, then pathname resolution iscomplete:</p><ol><li><p>This is the last pathname component of the pathname.</p></li><li><p>The pathname has no trailing slash.</p></li><li><p>The function is required to act on the symbolic link itself, or certain arguments direct that the function act on the symboliclink itself.</p></li></ol><p>In all other cases, the system shall prefix the remaining pathname, if any, with the contents of the symbolic link. If thecombined length exceeds {PATH_MAX}, and the implementation considers this to be an error, <i>errno</i> shall be set to[ENAMETOOLONG] and an error indication shall be returned. Otherwise, the resolved pathname shall be the resolution of the pathnamejust created. If the resulting pathname does not begin with a slash, the predecessor of the first filename of the pathname is takento be the directory containing the symbolic link.</p><p>If the system detects a loop in the pathname resolution process, it shall set <i>errno</i> to [ELOOP] and return an errorindication. The same may happen if during the resolution process more symbolic links were followed than the implementation allows.This implementation-defined limit shall not be smaller than {SYMLOOP_MAX}.</p><p>The special filename dot shall refer to the directory specified by its predecessor. The special filename dot-dot shall refer tothe parent directory of its predecessor directory. As a special case, in the root directory, dot-dot may refer to the rootdirectory itself.</p><p>A pathname consisting of a single slash shall resolve to the root directory of the process. A null pathname shall not besuccessfully resolved. A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner,although more than two leading slashes shall be treated as a single slash.</p><h3><a name="tag_04_12"></a>Process ID Reuse</h3><p>A process group ID shall not be reused by the system until the process group lifetime ends.</p><p>A process ID shall not be reused by the system until the process lifetime ends. In addition, if there exists a process groupwhose process group ID is equal to that process ID, the process ID shall not be reused by the system until the process grouplifetime ends. A process that is not a system process shall not have a process ID of 1.</p><h3><a name="tag_04_13"></a>Scheduling Policy</h3><p>A scheduling policy affects process or thread ordering:</p><ul><li><p>When a process or thread is a running thread and it becomes a blocked thread</p></li><li><p>When a process or thread is a running thread and it becomes a preempted thread</p></li><li><p>When a process or thread is a blocked thread and it becomes a runnable thread</p></li><li><p>When a running thread calls a function that can change the priority or scheduling policy of a process or thread</p></li><li><p>In other scheduling policy-defined circumstances</p></li></ul><p>Conforming implementations shall define the manner in which each of the scheduling policies may modify the priorities orotherwise affect the ordering of processes or threads at each of the occurrences listed above. Additionally, conformingimplementations shall define in what other circumstances and in what manner each scheduling policy may modify the priorities oraffect the ordering of processes or threads.</p><h3><a name="tag_04_14"></a>Seconds Since the Epoch</h3><p>A value that approximates the number of seconds that have elapsed since the Epoch. A Coordinated Universal Time name (specifiedin terms of seconds (<i>tm_sec</i>), minutes (<i>tm_min</i>), hours (<i>tm_hour</i>), days since January 1 of the year(<i>tm_yday</i>), and calendar year minus 1900 (<i>tm_year</i>)) is related to a time represented as seconds since the Epoch,according to the expression below.</p><p>If the year is <1970 or the value is negative, the relationship is undefined. If the year is >=1970 and the value isnon-negative, the value is related to a Coordinated Universal Time name according to the C-language expression, where<i>tm_sec</i>, <i>tm_min</i>, <i>tm_hour</i>, <i>tm_yday</i>, and <i>tm_year</i> are all integer types:</p><blockquote><pre><i>tm_sec</i> <tt>+</tt> <i>tm_min</i><tt>*60 +</tt> <i>tm_hour</i><tt>*3600 +</tt> <i>tm_yday</i><tt>*86400 + (</tt><i>tm_year</i><tt>-70)*31536000 + ((</tt><i>tm_year</i><tt>-69)/4)*86400 - ((</tt><i>tm_year</i><tt>-1)/100)*86400 + ((</tt><i>tm_year</i><tt>+299)/400)*86400</tt></pre></blockquote><p>The relationship between the actual time of day and the current value for seconds since the Epoch is unspecified.</p><p>How any changes to the value of seconds since the Epoch are made to align to a desired relationship with the current actual timeare made is implementation-defined. As represented in seconds since the Epoch, each and every day shall be accounted for by exactly86400 seconds. <basefont size="2"></p><dl><dt><b>Note:</b></dt><dd>The last three terms of the expression add in a day for each year that follows a leap year starting with the first leap yearsince the Epoch. The first term adds a day every 4 years starting in 1973, the second subtracts a day back out every 100 yearsstarting in 2001, and the third adds a day back in every 400 years starting in 2001. The divisions in the formula are integerdivisions; that is, the remainder is discarded leaving only the integer quotient.</dd></dl><basefont size="3"> <h3><a name="tag_04_15"></a>Semaphore</h3><p>A minimum synchronization primitive to serve as a basis for more complex synchronization mechanisms to be defined by theapplication program.</p><p>For the semaphores associated with the Semaphores option, a semaphore is represented as a shareable resource that has anon-negative integer value. When the value is zero, there is a (possibly empty) set of threads awaiting the availability of thesemaphore.</p><p>For the semaphores associated with the X/Open System Interface Extension (XSI), a semaphore is a positive integer (0 through32767). The <a href="../functions/semget.html"><i>semget</i>()</a> function can be called to create a set or array of semaphores. Asemaphore set can contain one or more semaphores up to an implementation-defined value.</p><h5><a name="tag_04_15_00_01"></a>Semaphore Lock Operation</h5><p>An operation that is applied to a semaphore. If, prior to the operation, the value of the semaphore is zero, the semaphore lockoperation shall cause the calling thread to be blocked and added to the set of threads awaiting the semaphore; otherwise, the valueshall be decremented.</p><h5><a name="tag_04_15_00_02"></a>Semaphore Unlock Operation</h5><p>An operation that is applied to a semaphore. If, prior to the operation, there are any threads in the set of threads awaitingthe semaphore, then some thread from that set shall be removed from the set and becomes unblocked; otherwise, the semaphore valueshall be incremented.</p><h3><a name="tag_04_16"></a>Thread-Safety</h3><p>Refer to the System Interfaces volume of IEEE Std 1003.1-2001, <a href="../functions/xsh_chap02_09.html">Section 2.9,Threads</a>.</p><h3><a name="tag_04_17"></a>Tracing</h3><p>The trace system allows a traced process to have a selection of events created for it. Traces consist of streams of trace eventtypes.</p><p>A trace event type is identified on the one hand by a trace event type name, also referenced as a trace event name, and on theother hand by a trace event type identifier. A trace event name is a human-readable string. A trace event type identifier is anopaque identifier used by the trace system. There shall be a one-to-one relationship between trace event type identifiers and traceevent names for a given trace stream and also for a given traced process. The trace event type identifier shall be generatedautomatically from a trace event name by the trace system either when a trace controller process invokes <a href="../functions/posix_trace_trid_eventid_open.html"><i>posix_trace_trid_eventid_open</i>()</a> or when an instrumented applicationprocess invokes <a href="../functions/posix_trace_eventid_open.html"><i>posix_trace_eventid_open</i>()</a>. Trace event typeidentifiers are used to filter trace event types, to allow interpretation of user data, and to identify the kind of trace pointthat generated a trace event.</p><p>Each trace event shall be of a particular trace event type, and associated with a trace event type identifier. The execution ofa trace point shall generate a trace event if a trace stream has been created and started for the process that executed the tracepoint and if the corresponding trace event type identifier is not ignored by filtering.</p><p>A generated trace event shall be recorded in a trace stream, and optionally also in a trace log if a trace log is associatedwith the trace stream, except that:</p><ul><li><p>For a trace stream, if no resources are available for the event, the event is lost.</p></li><li><p>For a trace log, if no resources are available for the event, or a flush operation does not succeed, the event is lost.</p></li></ul><p>A trace event recorded in an active trace stream may be retrieved by an application having the appropriate privileges.</p><p>A trace event recorded in a trace log may be retrieved by an application having the appropriate privileges after opening thetrace log as a pre-recorded trace stream, with the function <a href="../functions/posix_trace_open.html"><i>posix_trace_open</i>()</a>.</p><p>When a trace event is reported it is possible to retrieve the following:</p><ul><li><p>A trace event type identifier</p></li><li><p>A timestamp</p></li><li><p>The process ID of the traced process, if the trace event is process-dependent</p></li><li><p>Any optional trace event data including its length</p></li><li><p>If the Threads option is supported, the thread ID, if the trace event is process-dependent</p></li><li><p>The program address at which the trace point was invoked</p></li></ul><p>Trace events may be mapped from trace event types to trace event names. One such mapping shall be associated with each tracestream. An active trace stream is associated with a traced process, and also with its children if the Trace Inherit option issupported and also the inheritance policy is set to _POSIX_TRACE_INHERIT. Therefore each traced process has a mapping of the traceevent names to trace event type identifiers that have been defined for that process.</p><p>Traces can be recorded into either trace streams or trace logs.</p><p>The implementation and format of a trace stream are unspecified. A trace stream need not be and generally is not persistent. Atrace stream may be either active or pre-recorded:</p><ul><li><p>An active trace stream is a trace stream that has been created and has not yet been shut down. It can be of one of the twofollowing classes:</p><ol><li><p>An active trace stream without a trace log that was created with the <a href="../functions/posix_trace_create.html"><i>posix_trace_create</i>()</a> function</p></li>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -