UNIX standardization and Implementation Options

Source: Internet
Author: User

POSIX.1 Version 2001 includes functions specified by the iso c standard. Its interfaces are divided into two types: required interfaces and optional interfaces. The optional interfaces are further divided into 50 zones by function. Table 1 summarizes the programming interfaces that are not discarded based on their respective Option Code. The option code is an abbreviation of 2-3 characters to identify the interface that belongs to each functional area. The option code highlights the text on the relevant pages of the manual, indicating that the interface depends on the support for specific options. Many options handle real-time scaling.

Table 1 POSIX.1 optional interface groups and code (SUS, Single UNIX Specification)

Code SUS mandatory requirements Symbol constant Description
ADV   _ POSIX_ADVISORY_INFO Creation information (Real-Time)
AIO   _ POSIX_ASYNCHRONOUS_IO Asynchronous input and output (Real-Time)
BAR   _ POSIX_BARRIERS Barrier (Real-Time)
CPT   _ POSIX_CPUTIME Process CPU clock (Real-Time)
CS   _ POSIX_CLOCK_SELECTION Clock selection (Real-Time)
CX Yes   Iso c standard extension
FSC Yes _ POSIX_FSYNC File synchronization
IP6   _ POSIX_IPV6 IPv6 Interface
MF Yes _ POSIX_MAPPED_FILES Store ing files
ML   _ POSIX_MEMLOCK Process storage zone lock (Real-Time)
MLR   _ POSIX_MEMLOCK_RANGE Lock storage area (Real-Time)
MON   _ POSIX_MONOTONIC_CLOCK Monotonous clock (Real-Time)
Flat Yes _ POSIX_MEMORY_PROTECTION Storage Protection
MSG   _ POSIX_MESSAGE_PASSING Message transmission (Real-Time)
MX     IEC 60559 Floating Point Options
PIO   _ POSIX_PRIORITIZED_IO Priority Input and Output
PS   _ POSIX_PRIORITIZED_SCHEDULING Process Scheduling (Real-Time)
RS   _ POSIX_RAW_SOCKETS Original socket
RTS   _ POSIX_REALTIME_SIGNALS Real-time signal expansion
SEM   _ POSIX_SEMAPHORES Semaphores (Real-Time)
SHM   _ POSIX_SHARED_MEMORY_OBJECTS Shared storage objects (Real-Time)
SIO   _ POSIX_SYNCHRONIZED_IO Synchronous input and output (Real-Time)
SPI   _ POSIX_SPIN_LOCKS Spin lock (Real-Time)
SPNs   _ POSIX_SPAWN Generation (Real-Time)
SS   _ POSIX_SPORADIC_SERVER Server (Real-Time)
TCT   _ POSIX_THREAD_CPUTIME Thread CPU clock (Real-Time)
TEF   _ POSIX_TRACE_EVENT_FILTER Tracking Event Filter
THR Yes _ POSIX_THREADS Thread
TMO   _ POSIX_TIMEOUTS Timeout (Real-Time)
TMR   _ POSIX_TIMERS Timer (Real-Time)
TPI   _ POSIX_THREAD_PRIO_INHERIT Thread priority integration (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 Tracking
TRI   _ POSIX_TRACE_INHERIT Tracking inheritance
TRL   _ POSIX_TRACE_LOG Tracking log
TSA Yes _ POSIX_THREAD_ATTR_STACKADDR Thread stack address attributes
TSF Yes _ POSIX_THREAD_SAFE_FUNCTION Thread-safe Functions
TSH Yes _ POSIX_THREAD_PROCESS_SHARED Synchronization shared by thread Processes
TSP   _ POSIX_THREAD_SPORADIC_SERVER Thread-free server (Real-Time)
TSS Yes _ POSIX_THREAD_ATTR_STACKSIZE Thread stack address size
TYM   _ POSIX_TYPED_MEMORY_OBJECTS Typed storage objects (Real-Time)
XSI Yes _ XOPEN_UNIX X/Open extension Interface
XSR   _ XOPEN_STREAMS XSI STREAMS

Table 1 lists the POSIX.1 options. If we want to write some portable applications that are related to all the supported options, A portable method is required to determine whether an implementation supports a given option.

As with restrictions, Single UNIX Specification defines three processing methods:

(1) the options are defined in <unistd. h> during compilation.

(2) The options irrelevant to files or directories are determined using the sysconf function.

(3) options related to files or directories are discovered by calling the pathconf or fpathconf function.

The options include the symbols in the 3rd column of table 1 and the symbols in the column 2 and 3. If the symbolic constant is not defined, sysconf, pathconf, or fpathconf must be used to determine whether the option is supported. In this case, the name prefix _ POSIX of these functions must be replaced with _ SC or _ PC. For constants prefixed with _ XOPEN, _ SC or _ PC strings must be placed before the name parameter.

If the platform defines symbolic constants, there are three possibilities:

(1) If the definition value of a symbolic constant is-1, the platform does not support the corresponding options.

(2) If the definition value of a symbolic constant is greater than 0, the platform supports corresponding options.

(3) If the definition value of a symbolic constant is 0, sysconf, pathconf, or fpathconf must be called to check whether the corresponding options are supported.

Table 2 sysconf options and name Parameters

Option name Description Name Parameter
_ POSIX_JOB_CONTROL Specifies whether this implementation supports job control. _ SC _JOB_CONTROL
_ POSIX_READER_WRITER_LOCKS Indicates whether this implementation supports reader-writer locks. _ SC _READER_WRITER_LOCKS
_ POSIX_SAVED_IDS Specifies whether this implementation supports saved set-uesr-ID and saved set-group-ID. _ SC _SAVED_IDS
_ POSIX_SHELL Whether POSIX shell is supported _ SC _SHELL
_ POSIX_VERSION POSIX.1 version _ SC _VERSION
_ XOPEN_CRYPT Indicates whether XSI encryption lists are supported. _ SC _XOPEN_CRYPT
_ XOPEN_LEGACY Indicates whether the implementation supports the XSI legacy region group. _ SC _XOPEN_LEGACY
_ XOPEN_REALTIME Whether XSI real-time quota group is supported _ SC _XOPEN_REALTIME
_ XOPEN_REALTIME_THREADS Indicates whether XIS Real-Time Thread groups are supported by this implementation. _ SC _XOPEN_REALTIME_THREADS
_ XOPEN_VERSION Specify the XSI version _ SC _XOPEN_VERSION

Table 3 options and name parameters of pathconf and fpathconf

Option name Description Name Parameter
_ POSIX_CHOWN_RESTRICTED Specifies whether chown is restricted. _ PC_CHOWN_RESTRICTED
_ POSIX_NO_TRUNC Indicates whether an error occurs when the path name is longer than NAME_MAX. _ PC_NO_TRUNC
_ POSIX_VDISABLE If defined, you can use this value to disable special characters of the terminal. _ PC_VDISABLE
_ POSIX_ASYNC_IO Specifies whether asynchronous I/O can be used for associated files _ PC_ASYNC_IO
_ POSIX_PRIO_IO Specifies whether priority I/O can be used for associated files _ PC_PRIO_IO
_ POSIX_SYNC_IO Specifies whether synchronization I/O can be used for associated files _ PC_SYNC_IO

If the system limits are the same, the following points are worth noting about how to handle sysconf, pathconf, and fpathconf:

(1) the return value of _ SC _VERSION indicates the year (in 4 digits) and month (in 2 digits) related to the standard ). This value may be 198808L, 199029L, and 199506L, or other values of later versions of this version. The value related to SUS v3 is 200w.l.

(2) the return value of _ SC _XOPEN_VERSION indicates the XSI version that the system complies. The value associated with SUS v3 is 600.

(3) The values of _ SC _JOB_CONTROL, _ SC _SAVED_IDS, and _ PC_VDISABLE no longer indicate the optional functions. These functions are no longer required since SUS v3, but these symbols are retained for backward compatibility.

(4) If the specified pathname or filedes does not support this function, _ PC_CHOWN_RESTRICTED and _ PC_NO_TRUNC return-1 without changing errno.

(5) The file referenced by _ PC_CHOWN_RESTRICTED must be a file or directory. If it is a directory, the return value indicates whether the option can be applied to each file in the directory.

(6) The file referenced by _ PC_NO_TRUNC must be a directory. The return value can be used for each file name in the directory.

(7) The file referenced by _ PC_VDISABLE must be a terminal file.

To comply with SUS v3, if an option symbol is defined, its value should be set to 0,-1, or 200112. If a function is not defined, that is, the system does not define a symbolic constant or the corresponding _ SC or _ PC name, the record item is marked as "undefined ". In contrast, the "defined" record indicates that the symbolic constant has been defined, but no value is specified (for example: # define _ POSIX_THREADS ). If the system defines a symbolic constant, but its value is-1 or 0, but the corresponding sysconf or pathconf call returns-1, the record is marked as "not supported ".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.