📄 xbd_chap04.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>Rationale</title></head><body><basefont size="3"> <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</font></center><hr size="2" noshade><h3><a name="tag_01_04"></a>General Concepts</h3><h4><a name="tag_01_04_01"></a>Concurrent Execution</h4><p>There is no additional rationale provided for this section.</p><h4><a name="tag_01_04_02"></a>Directory Protection</h4><p>There is no additional rationale provided for this section.</p><h4><a name="tag_01_04_03"></a>Extended Security Controls</h4><p>Allowing an implementation to define extended security controls enables the use of IEEE Std 1003.1-2001 inenvironments that require different or more rigorous security than that provided in POSIX.1. Extensions are allowed in two areas:privilege and file access permissions. The semantics of these areas have been defined to permit extensions with reasonable, but notexact, compatibility with all existing practices. For example, the elimination of the superuser definition precludes identifying aprocess as privileged or not by virtue of its effective user ID.</p><h4><a name="tag_01_04_04"></a>File Access Permissions</h4><p>A process should not try to anticipate the result of an attempt to access data by <i>a priori</i> use of these rules. Rather, itshould make the attempt to access data and examine the return value (and possibly <i>errno</i> as well), or use <a href="../functions/access.html"><i>access</i>()</a>. An implementation may include other security mechanisms in addition to thosespecified in POSIX.1, and an access attempt may fail because of those additional mechanisms, even though it would succeed accordingto the rules given in this section. (For example, the user's security level might be lower than that of the object of the accessattempt.) The supplementary group IDs provide another reason for a process to not attempt to anticipate the result of an accessattempt.</p><h4><a name="tag_01_04_05"></a>File Hierarchy</h4><p>Though the file hierarchy is commonly regarded to be a tree, POSIX.1 does not define it as such for three reasons:</p><ol><li><p>Links may join branches.</p></li><li><p>In some network implementations, there may be no single absolute root directory; see <i>pathname resolution</i>.</p></li><li><p>With symbolic links, the file system need not be a tree or even a directed acyclic graph.</p></li></ol><h4><a name="tag_01_04_06"></a>Filenames</h4><p>Historically, certain filenames have been reserved. This list includes <b>core</b>, <b>/etc/passwd</b>, and so on. Conformingapplications should avoid these.</p><p>Most historical implementations prohibit case folding in filenames; that is, treating uppercase and lowercase alphabeticcharacters as identical. However, some consider case folding desirable:</p><ul><li><p>For user convenience</p></li><li><p>For ease-of-implementation of the POSIX.1 interface as a hosted system on some popular operating systems</p></li></ul><p>Variants, such as maintaining case distinctions in filenames, but ignoring them in comparisons, have been suggested. Methods ofallowing escaped characters of the case opposite the default have been proposed.</p><p>Many reasons have been expressed for not allowing case folding, including:</p><ul><li><p>No solid evidence has been produced as to whether case-sensitivity or case-insensitivity is more convenient for users.</p></li><li><p>Making case-insensitivity a POSIX.1 implementation option would be worse than either having it or not having it, because:</p><ul><li><p>More confusion would be caused among users.</p></li><li><p>Application developers would have to account for both cases in their code.</p></li><li><p>POSIX.1 implementors would still have other problems with native file systems, such as short or otherwise constrained filenamesor pathnames, and the lack of hierarchical directory structure.</p></li></ul></li><li><p>Case folding is not easily defined in many European languages, both because many of them use characters outside the US ASCIIalphabetic set, and because:</p><ul><li><p>In Spanish, the digraph <tt>"ll"</tt> is considered to be a single letter, the capitalized form of which may be either<tt>"Ll"</tt> or <tt>"LL"</tt> , depending on context.</p></li><li><p>In French, the capitalized form of a letter with an accent may or may not retain the accent, depending on the country in whichit is written.</p></li><li><p>In German, the sharp ess may be represented as a single character resembling a Greek beta (ß) in lowercase, but as thedigraph <tt>"SS"</tt> in uppercase.</p></li><li><p>In Greek, there are several lowercase forms of some letters; the one to use depends on its position in the word. Arabic hassimilar rules.</p></li></ul></li><li><p>Many East Asian languages, including Japanese, Chinese, and Korean, do not distinguish case and are sometimes encoded incharacter sets that use more than one byte per character.</p></li><li><p>Multiple character codes may be used on the same machine simultaneously. There are several ISO character sets for Europeanalphabets. In Japan, several Japanese character codes are commonly used together, sometimes even in filenames; this is evidentlyalso the case in China. To handle case insensitivity, the kernel would have to at least be able to distinguish for which charactersets the concept made sense.</p></li><li><p>The file system implementation historically deals only with bytes, not with characters, except for slash and the null byte.</p></li><li><p>The purpose of POSIX.1 is to standardize the common, existing definition, not to change it. Mandating case-insensitivity wouldmake all historical implementations non-standard.</p></li><li><p>Not only the interface, but also application programs would need to change, counter to the purpose of having minimal changes toexisting application code.</p></li><li><p>At least one of the original developers of the UNIX system has expressed objection in the strongest terms to either requiringcase-insensitivity or making it an option, mostly on the basis that POSIX.1 should not hinder portability of application programsacross related implementations in order to allow compatibility with unrelated operating systems.</p></li></ul><p>Two proposals were entertained regarding case folding in filenames:</p><ol><li><p>Remove all wording that previously permitted case folding.</p><dl compact><dt>Rationale</dt><dd>Case folding is inconsistent with portable filename character set definition and filename definition (all characters exceptslash and null). No known implementations allowing all characters except slash and null also do case folding.</dd></dl></li><li><p>Change "though this practice is not recommended:" to "although this practice is strongly discouraged."</p><dl compact><dt>Rationale</dt><dd>If case folding must be included in POSIX.1, the wording should be stronger to discourage the practice.</dd></dl></li></ol><p>The consensus selected the first proposal. Otherwise, a conforming application would have to assume that case folding wouldoccur when it was not wanted, but that it would not occur when it was wanted.</p><h4><a name="tag_01_04_07"></a>File Times Update</h4><p>This section reflects the actions of historical implementations. The times are not updated immediately, but are only marked forupdate by the functions. An implementation may update these times immediately.</p><p>The accuracy of the time update values is intentionally left unspecified so that systems can control the bandwidth of a possiblecovert channel.</p><p>The wording was carefully chosen to make it clear that there is no requirement that the conformance document contain informationthat might incidentally affect file update times. Any function that performs pathname resolution might update several<i>st_atime</i> fields. Functions such as <a href="../functions/getpwnam.html"><i>getpwnam</i>()</a> and <a href="../functions/getgrnam.html"><i>getgrnam</i>()</a> might update the <i>st_atime</i> field of some specific file or files. It isintended that these are not required to be documented in the conformance document, but they should appear in the systemdocumentation.</p><h4><a name="tag_01_04_08"></a>Host and Network Byte Order</h4><p>There is no additional rationale provided for this section.</p><h4><a name="tag_01_04_09"></a>Measurement of Execution Time</h4><p>The methods used to measure the execution time of processes and threads, and the precision of these measurements, may varyconsiderably depending on the software architecture of the implementation, and on the underlying hardware. Implementations can alsomake tradeoffs between the scheduling overhead and the precision of the execution time measurements. IEEE Std 1003.1-2001does not impose any requirement on the accuracy of the execution time; it instead specifies that the measurement mechanism and itsprecision are implementation-defined.</p><h4><a name="tag_01_04_10"></a>Memory Synchronization</h4><p>In older multi-processors, access to memory by the processors was strictly multiplexed. This meant that a processor executingprogram code interrogates or modifies memory in the order specified by the code and that all the memory operation of all theprocessors in the system appear to happen in some global order, though the operation histories of different processors areinterleaved arbitrarily. The memory operations of such machines are said to be sequentially consistent. In this environment,threads can synchronize using ordinary memory operations. For example, a producer thread and a consumer thread can synchronizeaccess to a circular data buffer as follows:</p><blockquote><pre><tt>int rdptr = 0;int wrptr = 0;data_t buf[BUFSIZE];<br>Thread 1: while (work_to_do) { int next;<br> buf[wrptr] = produce(); next = (wrptr + 1) % BUFSIZE; while (rdptr == next) ; wrptr = next;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -