POSIX — What is the Portable Operating System Interface?
Short Bytes: Standards are what make my computer able to communicate with yours, they make websites render the same on our respective computers, they allow our computers to interpret a live video feed do that we all see the same thing. But standard extend beyond the sharing of content between two computers, some standards define specific patterns that allow much more than network or file interoperability. POSIX is one such standard.
POSIX, pronounced ‘pawzix’, is the Portable Operating System Interface, but what does that even mean? First, we need to determine the scope of the word ‘portable’ in this context and then understand what is meant by the word ‘interface’. To understand what these words mean, you have to first understand that they’re inextricably connected.
The word ‘portable’ in POSIX is with respect to the source code (not the binary product of compiling the source code). Now, we need to understand what’s meant by the word ‘interface’. In programming, an interface is where your code can communicate with other code. The interface expects your code to provide a specific type of information and your code expects a specific type to be returned. A good example of this is the fopen() function in C, it expects two pieces of information, the path to the file and the mode that the file is being open in, with this information, the operating system returns another specific piece of information called a file descriptor. The file descriptor can then be used to read from or write to the file. This is an interface. All of this means that POSIX compliant code can be compiled for any POSIX compliant operating system with little to no changes and is hence portable.
A list of POSIX defined interfaces is available here, but despite how long it is, it’s possible that it isn’t complete. POSIX doesn’t stop at system calls, POSIX defines a standard for operating system shells (command line interfaces), system utilities such as awk and echo, system libraries, and much more.
The POSIX standard started as a project of Richard Stallman’s in 1985 and was later formalized as a standard in IEEE Std 1003.1-1988, which, as the name implies, was published in 1988. Since then many additions and extensions have been made to the POSIX standard making a family of standards known formally as IEEE 1003 and is recognized as an international standard with the designation SO/IEC 9945, or informally as the POSIX family of standards.
While it isn’t necessary for an operating system to be POSIX compliant, and much less so POSIX certified, it allows developers to create applications, tools, and platforms on many operating systems using much of the same code. Conversely, it isn’t necessary to write POSIX-compliant code, but it will help you significantly in porting your projects to other operating systems, this means that learning to write code that is POSIX-compliant has valuable in and of itself and can surely benefit your career. Major projects like Gnome and KDE rely on this standard to ensure that they can run on many different operating systems. Linux is known to support most of the POSIX system call interfaces as well as a large extension to the POSIX specification, known as the Linux Standard Base, which aims to unify Linux distributions in both code and binary support.
Do any of the Fossbytes readers have POSIX compliant projects that they’d like to share? Let us know in the comments below.
Also Read: Microsoft And Linux — A Song Of Mice And Ire