Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5607152
  • 博文数量: 922
  • 博客积分: 19333
  • 博客等级: 上将
  • 技术积分: 11226
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-27 14:33
文章分类

全部博文(922)

文章存档

2023年(1)

2020年(2)

2019年(1)

2017年(1)

2016年(3)

2015年(10)

2014年(17)

2013年(49)

2012年(291)

2011年(266)

2010年(95)

2009年(54)

2008年(132)

分类: LINUX

2011-12-25 10:04:30

++++++APUE读书笔记-02UNIX标准和实现-02UNIX标准++++++

 

2、UNIX标准
================================================
(1)ISO C
 在1989年晚些时候,用于C语言的ANSI Standard X3.1591989(ANSI标准)通过了认可。这个标准被国际标准ISO/IEC  9899:1990.采纳。ANSI是“American National Standards Institute”也就是美国国家标准协会的简称。它是ISO(“International Organization for Standardization”的简称,即国际标准化组织)中代表美国的一员。IEC是“International Electrotechnical Commission”的简称,即国际电工技术委员会(从本书第一版此处翻译看出,一般ISO C应该和ANSI C是一个东西 )。
 这个C标准现在被ISO/IEC 中的C程序语言的国际标准化工作组维护和开发,也就是ISO/IEC JTC1/SC22/WG14,简称WG14。ISO C标准的目的就是为不同种类的操作系统提供可移植的C程序,而不仅仅是在UNIX系统上面。这个标准不仅定义了C语言的语法和语义,也定义了一个标准库。这个标准库非常重要,当前绝大多数UNIX系统(例如我们本书所提到的几个系统)都提供其库函数的实现。
 在1999年,ISO C标准更新,并且被采纳为ISO/IEC 9899:1999,为数字处理方面的程序提供了极大的支持。这个变化,除了其中某些函数中的restrict关键字之外,并没有影响到本书中所提到的POSIX标准。而这个关键字就是用来告诉编译器那些指针可以被优化,优化的方法就是将引用对象的那个指针标记成在函数内部,只能通过那个指针来访问所引用的对象。
 和大多数的标准一样,在标准被采纳以及修改软件以适应被采纳的标准之间,总会有一个延迟。随着供应商编译系统的发展,他们会加入更多对最新版本的ISO C标准的支持。
 当前gcc编译器对ISO C 1999年版本的支持程度,可以大致参见 。
 ISO C库基于其标准所定义的头文件,被分成24个区域,下面表格列出了这个C标准所定义的头文件。POSIX.1标准包含了这些头文件,其他的标准也是。在表格中,我们也列出了本书中所涉及的四个系统(FreeBSD 5.2.1, Linux 2.4.22, Mac OS X 10.3, 和 Solaris 9)支持这些头文件的哪些。

ISO C标准定义的头文件
+------------------------------------------------------------------------------------------------------------+
|    Header    |   FreeBSD   |   Linux    |  Mac OS X   | Solaris |               Description                |
|              |    5.2.1    |   2.4.22   |    10.3     |    9    |                                          |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|    |      •      |     •      |      •      |    •    | verify program assertion                 |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|   |      •      |     •      |      •      |         | complex arithmetic support               |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|     |      •      |     •      |      •      |    •    | character types                          |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|     |      •      |     •      |      •      |    •    | error codes (Section 1.7)                |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|      |             |     •      |      •      |         | floating-point environment               |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|     |      •      |     •      |      •      |    •    | floating-point constants                 |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
| |      •      |     •      |      •      |    •    | integer type format conversion           |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|    |      •      |     •      |      •      |    •    | alternate relational operator macros     |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|    |      •      |     •      |      •      |    •    | implementation constants (Section 2.5)   |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|    |      •      |     •      |      •      |    •    | locale categories                        |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|      |      •      |     •      |      •      |    •    | mathematical constants                   |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|    |      •      |     •      |      •      |    •    | nonlocal goto (Section 7.10)             |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|    |      •      |     •      |      •      |    •    | signals (Chapter 10)                     |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|    |      •      |     •      |      •      |    •    | variable argument lists                  |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|   |      •      |     •      |      •      |    •    | boolean type and values                  |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|    |      •      |     •      |      •      |    •    | standard definitions                     |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|    |      •      |     •      |      •      |         | integer types                            |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|     |      •      |     •      |      •      |    •    | standard I/O library (Chapter 5)         |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|    |      •      |     •      |      •      |    •    | utility functions                        |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|    |      •      |     •      |      •      |    •    | string operations                        |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|    |             |     •      |             |         | type-generic math macros                 |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|      |      •      |     •      |      •      |    •    | time and date (Section 6.10)             |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|     |      •      |     •      |      •      |    •    | extended multibyte and wide character    |
|              |             |            |             |         | support                                  |
|--------------+-------------+------------+-------------+---------+------------------------------------------|
|    |      •      |     •      |      •      |    •    | wide character classification and        |
|              |             |            |             |         | mapping support                          |
+------------------------------------------------------------------------------------------------------------+

 这些ISO C头文件,依赖于操作系统所使用的C编译器的版本。例如,FreeBSD 5.2.1实用gcc的3.3.3版本,Linux 2.4.22使用gcc的3.3.1版本等,所以,要注意当前你操作系统使用的编译器版本。

(2)IEEE POSIX
 POSIX是一个电气电子工程师协会( 即Institute of Electrical and Electronics Engineers,简称IEEE)制定的协议族。POSIX(Portable Operating System Interface的简称),即可移植的操作系统接口。它原来只是指的 IEEE Standard 1003.11988,也就是操作系统接口,但是后来1003指定下,它被扩展包含许多标准和草案标准,包含了shell以及公共程序标准(1003.2)。
 本书所关注的是1003.1的操作系统接口标准,这个标准是为了增加应用程序在不同的UNIX系统环境下的可移植性。这个标准定义了一个遵从"POSIX"的操作系统所必须提供的服务,并且这个标准被许多的计算机供应商采纳。尽管1003.1标准基于UNIX操作系统,但是这个标准并不限于UNIX和类UNIX系统。实际上,许多提供操作系统的供应商都声称他们的操作系统除了包含一些专有的特性,也是遵从POSIX标准的。
 因为1003.1标准只定义了接口并没有定义实现,所以并没有系统调用库函数之间的区分。所有标准中的例程都是函数。
 各种标准都在发展,1003.1标准也是。这个标准的1988年版本,也就是IEEE Standard 1003.11988,被修改并且提交给了ISO,除了一些文本上的变化,它并没有添加新的接口。最终的文档作为IEEE Std 1003.11990(IEEE 1990]被发布,这也是international standard ISO/IEC 99451:1990。这个标准通常被称作POSIX.1,这也是我们本文所采用的标准。
 IEEE 1003.1工作组仍然在对这个标准进行一些修改。在1993年,一个校订版本的 IEEE 1003.1 标准被发布出来。它包含了1003.1-1990 标准 和1003.1b-1993 实时扩展标准。在1996年,这个标准又更新为international standard ISO/IEC 99451:1996,它包含了多线程编程的相关标准,被称作pthreads for POSIX threads。在1999年发行的 IEEE Standard 1003.1d-1999中,也添加了更多的实时接口。几年之前, IEEE Standard 1003.1j-2000 也发布了,包含了更多的实时接口,同时也发布了 IEEE Standard 1003.1q-2000,它为这个标准添加了实践跟踪扩展方面的内容。
 1003.1的2001版本被从它之前的版本中分离出来,因为它将一些1003.1增加的内容,1003.2 标准,以及Single UNIX Specification (简称SUS)的部分内容,Version 2 (more on this later),结合起来,最终的标准,也就是IEEE Standard 1003.1-2001,包含了如下的其他标准:
ISO/IEC 9945-1 (IEEE Standard 1003.1-1996), which includes
 IEEE Standard 1003.1-1990
 IEEE Standard 1003.1b-1993 (real-time extensions)
 IEEE Standard 1003.1c-1995 (pthreads)
 IEEE Standard 1003.1i-1995 (real-time technical corrigenda)
IEEE P1003.1a draft standard (system interface revision)
IEEE Standard 1003.1d-1999 (advanced real-time extensions)
IEEE Standard 1003.1j-2000 (more advanced real-time extensions)
IEEE Standard 1003.1q-2000 (tracing)
IEEE Standard 1003.2d-1994 (batch extensions)
IEEE P1003.2b draft standard (additional utilities)
Parts of IEEE Standard 1003.1g-2000 (protocol-independent interfaces)
ISO/IEC 9945-2 (IEEE Standard 1003.2-1993)
The Base Specifications of the Single UNIX Specification, version 2, which include
 System Interface Definitions, Issue 5
 Commands and Utilities, Issue 5
 System Interfaces and Headers, Issue 5
Open Group Technical Standard, Networking Services, Issue 5.2
ISO/IEC 9899:1999, Programming Languages - C

 下面的表格中,列出了所需要的和可选的被POSIX.1制定的头文件。因为POSIX.1 包含了ISO C标准,所以它也要求前面表格中列出的内容。这所有四个表格,也给出了本书所提到的系统支持其中的哪些头文件。

POSIX标准要求的头文件定义
+-----------------------------------------------------------------------------------------------------------+
|    Header     |   FreeBSD   |   Linux    |  Mac OS X   | Solaris |              Description               |
|               |    5.2.1    |   2.4.22   |    10.3     |    9    |                                        |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|     |      •      |     •      |      •      |    •    | directory entries (Section 4.21)       |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|      |      •      |     •      |      •      |    •    | file control (Section 3.14)            |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|    |      •      |     •      |      •      |    •    | filename-matching types                |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|       |      •      |     •      |      •      |    •    | pathname pattern-matching types        |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|        |      •      |     •      |      •      |    •    | group file (Section 6.4)               |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|      |      •      |     •      |      •      |    •    | network database operations            |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|        |      •      |     •      |      •      |    •    | password file (Section 6.2)            |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|      |      •      |     •      |      •      |    •    | regular expressions                    |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|        |      •      |     •      |      •      |    •    | tar archive values                     |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|    |      •      |     •      |      •      |    •    | terminal I/O (Chapter 18)              |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|     |      •      |     •      |      •      |    •    | symbolic constants                     |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|      |      •      |     •      |      •      |    •    | file times (Section 4.19)              |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|    |      •      |     •      |             |    •    | word-expansion types                   |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
| |      •      |     •      |      •      |    •    | Internet definitions (Chapter 16)      |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|     |      •      |     •      |      •      |    •    | socket local interfaces (Chapter 16)   |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
| | in.h>         |             |            |             |         |                                        |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
| | tcp.h>        |             |            |             |         | definitions                            |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|   |      •      |     •      |      •      |    •    | memory management declarations         |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
| | select.h>     |             |            |             |         |                                        |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
| | socket.h>     |             |            |             |         |                                        |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|   |      •      |     •      |      •      |    •    | file status (Chapter 4)                |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
| |      •      |     •      |      •      |    •    | process times (Section 8.16)           |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
| |      •      |     •      |      •      |    •    | primitive system data types (Section   |
|               |             |            |             |         | 2.8)                                   |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|     |      •      |     •      |      •      |    •    | UNIX domain socket definitions (       |
|               |             |            |             |         | Section 17.3)                          |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
| | utsname.h>    |             |            |             |         |                                        |
|---------------+-------------+------------+-------------+---------+----------------------------------------|
|   |      •      |     •      |      •      |    •    | process control (Section 8.6)          |
+-----------------------------------------------------------------------------------------------------------+

POSIX标准定义的XSI扩展头文件
+-----------------------------------------------------------------------------------------------------------+
|     Header     |   FreeBSD   |   Linux    |  Mac OS X   | Solaris  |             Description              |
|                |    5.2.1    |   2.4.22   |    10.3     |    9     |                                      |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|        |      •      |     •      |             |    •     | cpio archive values                  |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|       |      •      |     •      |      •      |    •     | dynamic linking                      |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|      |      •      |     •      |             |    •     | message display structures           |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|         |             |     •      |             |    •     | file tree walking (Section 4.21)     |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|       |             |     •      |      •      |    •     | codeset conversion utility           |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|    |      •      |     •      |      •      |    •     | language information constants       |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|      |      •      |     •      |      •      |    •     | definitions for pattern-matching     |
|                |             |            |             |          | function                             |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|    |      •      |     •      |      •      |    •     | monetary types                       |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|        |      •      |            |      •      |    •     | database operations                  |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|    |      •      |     •      |      •      |    •     | message catalogs                     |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|        |      •      |     •      |      •      |    •     | poll function (Section 14.5.2)       |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|      |      •      |     •      |      •      |    •     | search tables                        |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|     |      •      |     •      |      •      |    •     | string operations                    |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|      |      •      |     •      |      •      |    •     | system error logging (Section 13.4)  |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|    |      •      |     •      |      •      |    •     | user context                         |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|      |      •      |     •      |      •      |    •     | user limits                          |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|       |             |     •      |             |    •     | user accounting database             |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|     |      •      |     •      |      •      |    •     | IPC (Section 15.6)                   |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|     |      •      |     •      |             |    •     | message queues (Section 15.7)        |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
| | resource.h>    |             |            |             |          |                                      |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|     |      •      |     •      |      •      |    •     | semaphores (Section 15.8)            |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|     |      •      |     •      |      •      |    •     | shared memory (Section 15.9)         |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
| | statvfs.h>     |             |            |             |          |                                      |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|    |      •      |     •      |      •      |    •     | time types                           |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|   |      •      |     •      |      •      |    •     | additional date and time definitions |
|----------------+-------------+------------+-------------+----------+--------------------------------------|
|     |      •      |     •      |      •      |    •     | vector I/O operations (Section 14.7) |
+-----------------------------------------------------------------------------------------------------------+


POSIX标准定义的可选头文件
+-----------------------------------------------------------------------------------------------------------+
|    Header     |   FreeBSD    |    Linux    |   Mac OS X   | Solaris  |            Description             |
|               |    5.2.1     |   2.4.22    |     10.3     |    9     |                                    |
|---------------+--------------+-------------+--------------+----------+------------------------------------|
|        |      •       |      •      |      •       |    •     | asynchronous I/O                   |
|---------------+--------------+-------------+--------------+----------+------------------------------------|
|     |      •       |             |              |    •     | message queues                     |
|---------------+--------------+-------------+--------------+----------+------------------------------------|
|    |      •       |      •      |      •       |    •     | threads (Chapters 11 and 12)       |
|---------------+--------------+-------------+--------------+----------+------------------------------------|
|      |      •       |      •      |      •       |    •     | execution scheduling               |
|---------------+--------------+-------------+--------------+----------+------------------------------------|
| |      •       |      •      |      •       |    •     | semaphores                         |
|---------------+--------------+-------------+--------------+----------+------------------------------------|
|      |              |      •      |              |          | real-time spawn interface          |
|---------------+--------------+-------------+--------------+----------+------------------------------------|
|    |              |      •      |              |    •     | XSI STREAMS interface (Section     |
|               |              |             |              |          | 14.4)                              |
|---------------+--------------+-------------+--------------+----------+------------------------------------|
|      |              |             |              |          | event tracing                      |
+-----------------------------------------------------------------------------------------------------------+


 在本文中,我们讨论POSIX.1的2001版本,这个版本包含了ISO C所指定的函数。它的接口被分为要求的和可选的两个部分。可选部分接口又根据其功能被分成50个段。这些段包含下面表中列出的还未过时的编程接口,以及它们各自的选项代码。选项代码一半就是2到3个字符的简称,这简称有助于标记接口所属的功能域。若相应接口依赖于选项(???)的支持,那么其选项代码在man手册中,以高亮文本方式显示出来,多数的选项都和实时扩展相关。

POSIX.1可选接口组和代码
+------------------------------------------------------------------------------------------------------+
| Code | SUS mandatory |         Symbolic constant         |                Description                |
|------+---------------+-----------------------------------+-------------------------------------------|
| ADV  |               | _POSIX_ADVISORY_INFO              | advisory information (real-time)          |
|------+---------------+-----------------------------------+-------------------------------------------|
| AIO  |               | _POSIX_ASYNCHRONOUS_IO            | asynchronous input and output (real-time) |
|------+---------------+-----------------------------------+-------------------------------------------|
| BAR  |               | _POSIX_BARRIERS                   | barriers (real-time)                      |
|------+---------------+-----------------------------------+-------------------------------------------|
| CPT  |               | _POSIX_CPUTIME                    | process CPU time clocks (real-time)       |
|------+---------------+-----------------------------------+-------------------------------------------|
| CS   |               | _POSIX_CLOCK_SELECTION            | clock selection (real-time)               |
|------+---------------+-----------------------------------+-------------------------------------------|
| CX   |       •       |                                   | extension to ISO C standard               |
|------+---------------+-----------------------------------+-------------------------------------------|
| FSC  |       •       | _POSIX_FSYNC                      | file synchronization                      |
|------+---------------+-----------------------------------+-------------------------------------------|
| IP6  |               | _POSIX_IPV6                       | IPv6 interfaces                           |
|------+---------------+-----------------------------------+-------------------------------------------|
| MF   |       •       | _POSIX_MAPPED_FILES               | memory-mapped files                       |
|------+---------------+-----------------------------------+-------------------------------------------|
| ML   |               | _POSIX_MEMLOCK                    | process memory locking (real-time)        |
|------+---------------+-----------------------------------+-------------------------------------------|
| MLR  |               | _POSIX_MEMLOCK_RANGE              | memory range locking (real-time)          |
|------+---------------+-----------------------------------+-------------------------------------------|
| MON  |               | _POSIX_MONOTONIC_CLOCK            | monotonic clock (real-time)               |
|------+---------------+-----------------------------------+-------------------------------------------|
| MPR  |       •       | _POSIX_MEMORY_PROTECTION          | memory protection                         |
|------+---------------+-----------------------------------+-------------------------------------------|
| MSG  |               | _POSIX_MESSAGE_PASSING            | message passing (real-time)               |
|------+---------------+-----------------------------------+-------------------------------------------|
| MX   |               |                                   | IEC 60559 floating-point option           |
|------+---------------+-----------------------------------+-------------------------------------------|
| PIO  |               | _POSIX_PRIORITIZED_IO             | prioritized input and output              |
|------+---------------+-----------------------------------+-------------------------------------------|
| PS   |               | _POSIX_PRIORITIZED_SCHEDULING     | process scheduling (real-time)            |
|------+---------------+-----------------------------------+-------------------------------------------|
| RS   |               | _POSIX_RAW_SOCKETS                | raw sockets                               |
|------+---------------+-----------------------------------+-------------------------------------------|
| RTS  |               | _POSIX_REALTIME_SIGNALS           | real-time signals extension               |
|------+---------------+-----------------------------------+-------------------------------------------|
| SEM  |               | _POSIX_SEMAPHORES                 | semaphores (real-time)                    |
|------+---------------+-----------------------------------+-------------------------------------------|
| SHM  |               | _POSIX_SHARED_MEMORY_OBJECTS      | shared memory objects (real-time)         |
|------+---------------+-----------------------------------+-------------------------------------------|
| SIO  |               | _POSIX_SYNCHRONIZED_IO            | synchronized input and output (real-time) |
|------+---------------+-----------------------------------+-------------------------------------------|
| SPI  |               | _POSIX_SPIN_LOCKS                 | spin locks (real-time)                    |
|------+---------------+-----------------------------------+-------------------------------------------|
| SPN  |               | _POSIX_SPAWN                      | spawn (real-time)                         |
|------+---------------+-----------------------------------+-------------------------------------------|
| SS   |               | _POSIX_SPORADIC_SERVER            | process sporadic server (real-time)       |
|------+---------------+-----------------------------------+-------------------------------------------|
| TCT  |               | _POSIX_THREAD_CPUTIME             | thread CPU time clocks (real-time)        |
|------+---------------+-----------------------------------+-------------------------------------------|
| TEF  |               | _POSIX_TRACE_EVENT_FILTER         | trace event filter                        |
|------+---------------+-----------------------------------+-------------------------------------------|
| THR  |       •       | _POSIX_THREADS                    | threads                                   |
|------+---------------+-----------------------------------+-------------------------------------------|
| TMO  |               | _POSIX_TIMEOUTS                   | timeouts (real-time)                      |
|------+---------------+-----------------------------------+-------------------------------------------|
| TMR  |               | _POSIX_TIMERS                     | timers (real-time)                        |
|------+---------------+-----------------------------------+-------------------------------------------|
| TPI  |               | _POSIX_THREAD_PRIO_INHERIT        | thread priority inheritance (real-time)   |
|------+---------------+-----------------------------------+-------------------------------------------|
| TPP  |               | _POSIX_THREAD_PRIO_PROTECT        | thread priority protection (real-time)    |
|------+---------------+-----------------------------------+-------------------------------------------|
| TPS  |               | _POSIX_THREAD_PRIORITY_SCHEDULING | thread execution scheduling (real-time)   |
|------+---------------+-----------------------------------+-------------------------------------------|
| TRC  |               | _POSIX_TRACE                      | trace                                     |
|------+---------------+-----------------------------------+-------------------------------------------|
| TRI  |               | _POSIX_TRACE_INHERIT              | trace inherit                             |
|------+---------------+-----------------------------------+-------------------------------------------|
| TRL  |               | _POSIX_TRACE_LOG                  | trace log                                 |
|------+---------------+-----------------------------------+-------------------------------------------|
| TSA  |       •       | _POSIX_THREAD_ATTR_STACKADDR      | thread stack address attribute            |
|------+---------------+-----------------------------------+-------------------------------------------|
| TSF  |       •       | _POSIX_THREAD_SAFE_FUNCTIONS      | thread-safe functions                     |
|------+---------------+-----------------------------------+-------------------------------------------|
| TSH  |       •       | _POSIX_THREAD_PROCESS_SHARED      | thread process-shared synchronization     |
|------+---------------+-----------------------------------+-------------------------------------------|
| TSP  |               | _POSIX_THREAD_SPORADIC_SERVER     | thread sporadic server (real-time)        |
|------+---------------+-----------------------------------+-------------------------------------------|
| TSS  |       •       | _POSIX_THREAD_ATTR_STACKSIZE      | thread stack address size                 |
|------+---------------+-----------------------------------+-------------------------------------------|
| TYM  |               | _POSIX_TYPED_MEMORY_OBJECTS       | typed memory objects (real-time)          |
|------+---------------+-----------------------------------+-------------------------------------------|
| XSI  |       •       | _XOPEN_UNIX                       | X/Open extended interfaces                |
|------+---------------+-----------------------------------+-------------------------------------------|
| XSR  |               | _XOPEN_STREAMS                    | XSI STREAMS                               |
+------------------------------------------------------------------------------------------------------+

 POSIX并没有包含超级用户的概念,但是它的一些特定操作要求有“特殊的权限”,POSIX将其留给了实现自己定义。遵从国防部安全性指导原则(Department of Defense security guidelines)的UNIX系统都有许多的安全级别。然而本文中,我们只是使用使用传统的属于,并且会指出那些操作需要超级用户权限。
 经过了几乎20多年的工作,这些标准日趋成熟和稳定。POSIX.1标准被一个开放性的工作组所维护,这个工作组被称作Austin Group ()。为确保它们的适用性,这些标准需要每隔一段时间就进行重申和更新。


(3)Single UNIX Specification
 这个单一UNIX规范(翻译起来读着很别扭,还不如不翻译^_^),是POSIX.1标准的超集,它额外地制定了一些接口,对基本的POSIX.1进行了扩展。这些完整的系统接口的集合被称作X/Open System Interface (XSI)。常数变量_XOPEN_UNIX所标记的那些接口,就是对基本POSIX.1接口进行了XSI扩展的那部分接口。
 XSI也定义了必须为一个遵从XSI的实现提供哪些POSIX.1的可选部分。这些部分包括文件同步,内存映射文件,内存保护,以及线程接口,这些在前面的途中被标记了 "SUS mandatory." 。只有遵从XSI的实现,才能够被称作UNIX系统。
 开放组织(The Open Group)拥有UNIX的商标,并且使用Single UNIX Specification来定义实现必须支持的接口,这样实现才能被称作UNIX系统。实现必须是文件描述一致的,通过了检测一致性的测试套件的测试,并且将许可证授权给UNIX商标。
 有些在XSI中定义的额外的接口是必需的,也有另外一些是可选的。这些接口基于基本的功能,被分成可选的组。如下:
Encryption: denoted by the _XOPEN_CRYPT symbolic constant
Real-time: denoted by the _XOPEN_REALTIME symbolic constant
Advanced real-time
Real-time threads: denoted by the _XOPEN_REALTIME_THREADS symbolic constant
Advanced real-time threads
Tracing
XSI STREAMS: denoted by the _XOPEN_STREAMS symbolic constant
Legacy: denoted by the _XOPEN_LEGACY symbolic constant

 Single UNIX Specification (SUS) 是由 The Open Group发行的,它是在1996年的时候由X/Open 和 the Open Software Foundation (OSF)两个组织合并形成的。X/Open以前发行X/Open Portability Guide,而此采取特定的标准并且填补一些确实的功能的空白。这些指导规范都是想要通过只遵循一系列公共标准的方式,来提高应用程序可移植特性的可能性。
 Single UNIX Specification的第一个版本通过X/Open在1994年发行。它也被称作"Spec 1170",因为它大致包含了1170个接口。它最初来自the Common Open Software Environment (COSE) ,这个COSE的目标是更好的提高应用程序在所有的UNIX操作系统上面的可移植特性。 COSE groupSun,IBM,惠普,Novell/ USL和OSFwent并不只是赞同了这些标准。他们还调查了一些通用的常用软件所使用的接口。而最终的1170个接口,就是从这些应用中选择出来的,也包含了X/Open Common Application Environment (CAE), Issue 4 (相应于其先前的规则the X/Open Portability Guide,它被称作"XPG4"),the System V Interface Definition (SVID), Edition 3, Level 1 interfaces, 以及the OSF Application Environment Specification (AES) Full Use interfaces。
 Single UNIX Specification的第二个版本,通过The Open Group,在1997年被发行。最新的版本添加了对线程的支持,实时接口,64位处理,大文件,以及加强的多字节字符处理。
 Single UNIX Specification (简称SUSv3)的第三个版本被The Open Group在2001年发行。SUSv3的基本规范和 IEEE Standard 1003.1-2001一样,并且分成四个小节:基本定义,系统接口,shell和通用工具,以及理念。SUSv3也包含了 X/Open Curses Issue 4, Version 2,但是它并不是POSIX.1的一个部分。
 在2002年,ISO将这个版本采纳为International Standard ISO/IEC 9945:2002,2003年的时候The Open Group将1003.1 标准更新,包含了一些技术的修正,然后ISO将这个采纳为 International Standard ISO/IEC 9945:2003。2004年4月, The Open Group公布了Single UNIX Specification版本3,2004修订版。在这个标准的正文中包含了更多的技术修正。

(4)FIPS
 FIPS是Federal Information Processing Standard的简称,也就是联邦信息处理标准。由美国政府出版,并且用于计算机系统的购置。 FIPS 1511 (1989年4月)基于IEEE Std. 1003.11988以及一个ANSI C标准草案。之后是FIPS 1512(1993年5月),它基于 IEEE Standard 1003.11990。FIPS 1512要求一些POSIX.1中做为可选部分列出的特性,这些可选的部分被 POSIX.1-2001强制性包含。
 POSIX.1 FIPS的作用就是它要求任何想要将POSIX.1兼容的计算机系统出售给美国政府的供应商支持一些POSIX.1可选的特性。这个POSI.1 FIPS已经被取消了,我们也不再对它进行更多的讨论。


参考:

 

 

阅读(737) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

vaqeteart2014-04-02 15:59:29

ISO C,不仅限于类Unix操作系统的,便于C语言移植的一套规范。

POSIX,是类Unix中的,便于在不同操作系统移植性的一套接口规范,后来许多非类Unix系统也参照此标准。

SUS,在POSIX上进行了一番扩展,变成了SUS, 并且相应的扩展部分增加的接口是XSI。符合SUS的才是Unix,否则不是,如Linux。


Unix包含如:
System V,继承自原来的AT&T Unix实验室。
4.4BSD,伯克利加利福尼亚大学发行的UNIX。
FreeBSD,在加利福尼亚大学停止对BSD开发之后,FreeBSD基于此的免费Unix。
可参照下节。
例如,属于System V的共享内存系统机制。
就是说:
该机制属于XSI,也即对POSIX扩展部分的内容,并且相应的Unix实现是System V。