Monday, August 4, 2014

Unix Prog: Unix Standardization(1)

1. Unix Standardization

1) ISO C: The intent of ISO C standard is to provide the portability of conforming C programs to a wide variety of operating systems, including the UNIX.
In 1999, ISO C standard was updated and approved as ISO/IEC 9899:1999, largely to improve the support for applications that perform numerical processing.

2) IEEE POSIX:
POSIX stands for portable operating system interface, which is a member of standards developed by IEEE. It defines the services must be provided by an operating system if it is to be "POSIX compliant". In 1996, the standard is again updated as ISO/IEC 9945-1:1996, which includes the interfaces for multithreaded programming, called pthreads for POSIX threads.
POSIX standard includes ISO C standard's functions and other functions(including library functions and system calls)

3) The Single Unix Specification
It is the superset of POSIX.1 standard system interfaces. It extends the POSIX.1 standard interfaces. And the complete set of of system interfaces is called X/Open System Interface(XSI). Only the XSI compliant system can be called UNIX system.

4) FIPS
FIPS stands for Federal Information Processing Standard. It was published by US government. It is based on POSIX.1 standard, and also list some POSIX.1 optional interfaces as "required interfaces". And all these interfaces are mandatory since POSIX.1 2001. FIPS has been withdrawn.

2. Unix System Implementations
1) Earliest branches of Unix System:

one at AT&T that led to System III and System V, which is called commercial Unix System;

one at the UC Berkeley that led to the 4.x BSD Implementations;

the research version of UNIX system, developed at the computing science Research Center of AT&T Bell Lab, that led to the Unix Time-Sharing system 8th edition, 9th edition and 10th edition(1990)

2) Unix System V Release 4
A product of AT&T System lab. It merges functionality from Unix System V Release 3.2(the Sun Operating System), 4.3BSD from UC Berkley, and the Xenlx system from Microsoft

3) 4.4 BSD
Produced by UC Berkley CSRG(Computer System Research Group)

4) Free BSD
It is based on the 4.4 BSD-Lite Operating System. This the continuation of BSD 4.x project after UC Berkeley decided to cancel that series.

5) Linux
It provides a rich Unix Programming Environment, and is freely available under the GNU Public Licence. It is used and enhanced by many developers across the world.

6) Mac OS X
It is different. The core is called "Darwin", and is based on a combination of the Mach Kernel and the free BSD OS.

7) Solaris
It is developed by Sun Microsystems. It is based on System V Release 4.

8) Other UNIX Systems:
AIX: IBM's Unix System
HP-UX: Hewlett-Packard's version of the Unix System
IRIX: Silicon Graphics Unix System
UnixWare: developed based on SVR4 and sold by SCO

3. Limits
Compile-time Limits: it can be defined at header files and any program can include them at compile-time.

Runtime limits that are not associated with a file or directory: we need to use sysconf function to retrieve the value.

Runtime limits that are associated with a file or directory: we need to use pathconf and fpathconf functions to retrieve the value.

shell:
For compile-time limits, we can open the /usr/include/limits.h to get all static values there. It includes all static limits like the minimum and maximum value of "short" type, "int" type, etc.
Besides <limits.h> compile-time limits could also be defined at other header files.
 ubuntu@ip-172-31-23-227:~$ less /usr/include/limits.h

 ......  
   
 /* Minimum and maximum values a `signed short int' can hold. */  
 # define SHRT_MIN   (-32768)  
 # define SHRT_MAX   32767  
   
 /* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */  
 # define USHRT_MAX   65535  
   
 /* Minimum and maximum values a `signed int' can hold. */  
 # define INT_MIN    (-INT_MAX - 1)  
 # define INT_MAX    2147483647  
   
 ......  

1) ISO C limits
All ISO C limits are compile-time limits, which are included at header files like <limits.h> <stdio.h> and <float.h>.

2) POSIX Limits
shell:
1) Open <posix1_lim.h>, it includes main limits' minimum values for POSIX.1 compliant systems. It just indicates that for all POSIX.1 compliant system, they have to have at least such value for specified limits. But these values are not the true limits of local system.
2) Open <local_lim.h>, it includes main limits' true value for local system. Basically, it just remove the "_POSIX_" prefix compared the corresponding limit in <posix1_lim.h>. But not all limits in <posix1_lim.h> exists at <local_lim.h>, if that is the case we have to use sysconf, pathconf or fpathconf api to retrieve at the run-time.
 ubuntu@ip-172-31-23-227:~$ less /usr/include/x86_64-linux-gnu/bits/posix1_lim.h  
 ......  
   
 /* These are the standard-mandated minimum values. */  
   
 /* Minimum number of operations in one list I/O call. */  
 #define _POSIX_AIO_LISTIO_MAX  2  
   
 /* Minimal number of outstanding asynchronous I/O operations. */  
 #define _POSIX_AIO_MAX     1  
   
 /* Maximum length of arguments to `execve', including environment. */  
 #define _POSIX_ARG_MAX     4096  
   
 ......  
 ubuntu@ip-172-31-23-227:~$ less /usr/include/x86_64-linux-gnu/bits/local_lim.h
 ......

 /* Maximum tty name length.  */
 #define TTY_NAME_MAX            32

 /* Maximum login name length.  This is arbitrary.  */
 #define LOGIN_NAME_MAX          256

 /* Maximum host name length.  */
 #define HOST_NAME_MAX           64

 ......

No comments:

Post a Comment