Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Programming in the UNIX Environment Hop Lee.

Similar presentations


Presentation on theme: "Advanced Programming in the UNIX Environment Hop Lee."— Presentation transcript:

1 Advanced Programming in the UNIX Environment Hop Lee

2 Ch02 UNIX Standardization and Implementations UNIX Standardization UNIX Implementations Relationship of Standardization and Implementations Limits Conflicts Between Standards

3 §2.1 UNIX Standardization ANSI C POSIX.1 XPG3

4 ANSI C The intent of ANSI C standard is to provide portability of comforming C programs to a wide variety of operating systems, not just UNIX. This standard defines not only the syntax and semantics of the programming language but also a standard library. This library can be divided into 15 areas based on the headers defined by the standard.

5 IEEE POSIX POSIX is a family of standards developed by the IEEE. POSIX stands for Portable Operating System Interface. Include 1003.1:the operating system interface, 1003.2:shell and utilities, 1003.7:system administration, etc. POSIX means IEEE Std.1003.1-1990, or ISO/IEC 9945-1:1990.

6 X/Open XPG3 X/Open is an internation group of computer vendors. They have produced a seven volume portability guide named X/Open Portability Guide, Issue 3[X/Open 1989]. We'll call it XPG3. XPG3 is a super-set of POSIX.1 approximately.

7 FIPS FIPS stands for Federal Information Processing Standard, and these standards are published by the U.S. Government. FIPS 151-1(April 1989) is based on the IEEE Std. 1003.1-1988 and a draft of the ANSI C standard. FIPS 151-1 requires some features that POSIX.1 lists as optional.

8 §2.1 UNIX Implementations The previous section described three standards are interface specifications. These standards are taken by vendors and turned into actual implementations. The ancestor of all implementations are Sixth Edition(1976) and Seventh Edition(1979) of the UNIX Time-Sharing System on PDP-11.

9 Three branches of the tree evolved: AT&T led to System III and System V(commercial versions); BSD led to the 4.xBSD implementations; AT&T Bell Laboratories led to the 8th, 9th, and 10th Editions(under continuing development).

10 System V Release 4 SVR4 is a product of AT&T UNIX System Laboratories. SVR4 conforms to both the POSIX 1003.1 standard and the X/Open XPG3 standard. AT&T also publishes the System V Interface Definition(SVID). Issue 3 of the SVID specifies the functionality that a UNIX system must offer to qualify as UNIX System V Release 4.

11 4.3+BSD The BSDs are produced and distributed by the Computer Systems Research Group at the University of California at Berkeley. Throughout this text we use the term 4.3+BSD to refer to the BSD system being described.

12 §2.3 Relationship of Standards and Implementations The standards that we've mentioned defined a subset of any actual system. The focus of this book is to describe two real UNIx systems: SVR4 and 4.3+BSD. Since both claim to be POSIX compliant we will also concentrate on the features that an implementations of these two systems.

13 §2.4 Limits There are many magic numbers and constants that are defined by the implementations. Three types of features are needed: compile-time options compile-time limits run-time limits The first two features can be defined in headers that any program can include at compile time. But run-time limits require the proecess to call a function to obtain the value of the limit.

14 Additinally, some limits can be fixed on a given implementation yet vary on another implementation. To solve the conflicts, three types of limits are provided: compile-time options and limits run-time limits that are not associated with a file or directory run-time limits that are associated with a file or directory

15 ANSI C Limits All the limits defined by ANSI C are compile- time limits. Check /usr/include/limits.h, /usr/include/linux/limits.h for the various limits and their values.

16 POSIX Limits POSIX.1 defines numerous constants that deal with implementation limits of the operating system. There are 33 different limits and constants. These are divided into the following eight categories: Invariant minimum values Invariant value: SSIZE_MAX Run-time increasable value: NGROUPS_MAS

17 Run-time invariant values (possible indeterminate): ARG_MAX, CHILD_MAX, OPEN_MAX, STREAM_MAX, and TZNAME_MAX Pathname variable values (possible indeterminate): LINK_MAX, MAX_CANON, MAX_INPUT, NAME_MAX, PATH_MAX, and PIPE_BUF Compile_time symbolic constants: _POSIX_SAVED_IDS, _POSIX_VERSION, and _POSIX_JOB_CONTROL

18 Execution-time symbolic constants: _POSIX_NO_TRUNC, _POSIX_VDISABLE, and _POSIX_CHOWN_RESTRICTED Obsolete constant: CLK_TCK Check /usr/include/bits/local_lim.h, /usr/include/bits/posix1_lim.h and /usr/include/bits/posix2_lim.h for the various limits and their values.

19 XPG3 Limits XPG3 defines seven constants that always appear in the header. POSIX.1 would call these invariant minimum values. XPG3 also defines the value PASS_MAX, which can appear in as the maximum number of significant characters in a password. POSIX.1 would call this value a run-time invariant value. The minimum acceptable value is 8.

20 sysconf, pathconf, and fpathconf Functions We've listed various minimum values that an implementation must support, but how do we find out the limits that a particular system actually supports? The run-time limits obtained by calling one of the following three functions: #include long sysconf(int name ); long pathconf(const char * pathname, int name ); long fpathconf(int fd, int name );

21 The parameters used by these three functions are restricted: Constants beginning with _SC_ are used by sysconf Constants beginning with _PC_ are used by either pathconf or fpathconf There are some restrictions for the pathname parameter to pathconf and the fd parameter to fpathconf. If any of those restriction aren't met, the results are undefined.

22 Example 2.1 Example 2.2


Download ppt "Advanced Programming in the UNIX Environment Hop Lee."

Similar presentations


Ads by Google