Fundamentals 17 min read

Why POSIX Matters: Unlocking Unix Compatibility and Portability

This article explains what POSIX is, its history, the organizations behind it, how it shaped Linux's success, and why understanding system calls versus library functions is essential for writing portable software across Unix‑like operating systems.

IT Services Circle
IT Services Circle
IT Services Circle
Why POSIX Matters: Unlocking Unix Compatibility and Portability

1. What is POSIX?

1. Concept

POSIX: Portable Operating System Interface of UNIX, abbreviated POSIX.

2. Publisher – IEEE

Published by the Institute of Electrical and Electronics Engineers (IEEE), a major authority in many technical fields. POSIX is a set of API standards defined by IEEE for software to run on various UNIX operating systems, formally known as IEEE 1003 and internationally as ISO/IEC 9945.

POSIX.1 has been accepted by ISO as ISO/IEC 9945-1:1990.

IEEE, headquartered in New York, is the world’s largest non‑profit professional technical society, developing standards for electrical, electronic, computer engineering, and related scientific fields.

3. POSIX Standard Download

Home page: http://blog.csdn.net/ablo_zhou

The standard can be read or downloaded online after registration at http://www.unix.org/version3/online.html .

Certification links: http://www.opengroup.org/certification/idx/posix.html and http://www.unix.org/version3/ieee_std.html

2. POSIX History

1. Origin

POSIX is the Unix standard. In 1974 Bell Labs released Unix publicly. To avoid antitrust issues and improve the early Unix, Bell Labs provided source code to universities, leading to many Unix‑like operating systems.

Examples:

Berkeley Software Distribution (BSD) from UC Berkeley.

System V Unix from Bell Labs.

Other vendor versions such as Sun Microsystems' Solaris, derived from BSD and System V.

In the mid‑1980s Unix vendors added incompatible features, causing chaos. IEEE began standardizing Unix development, later named “POSIX” by Richard Stallman.

The standard covers many aspects, including the C language system‑call interface, shell utilities, threads, and networking.

2. Who follows the standard?

Major Unix and Linux systems, as well as Apple’s Unix‑based operating system, adhere to POSIX.

Windows has considered POSIX compatibility since Windows NT to attract Unix users and now offers better support in Windows 10.

3. Why POSIX helped Linux succeed

POSIX gave Linux a clear set of APIs during its early years (1991‑1993), allowing rapid development and compatibility with other UNIX systems.

Early Linux kernels (0.01, 0.11) already included POSIX‑required symbols in /include/unistd.h, with Linus commenting on the effort.

POSIX compatibility enabled many Unix programs to be ported to Linux, giving Linux an advantage when Unix faced legal issues.

Below is an excerpt from Linus Torvalds' 1991 email requesting POSIX rules:

来自:[email protected](林纳斯·托瓦兹)
讨论组:comp.os.minix
主题:Gcc-1.40和一个有关POSIX的问题
信息名称: 1991 Jul 3 [email protected]
日期: 1991年7月3日,格林威治时间 10:00:50
各位网友好!
由于我现在正在MINIX系统下做一个项目,对POSIX标准很感兴趣。 有谁能向我提供一个(最好)是机器可读形式的最新的POSIX规则? 能有FTP地址就更好了。

Linus also wrote about the importance of POSIX:

POSIX标准是一个可以适用于数以百计的UNIX系统调用中的任意一个的一套冗长规则,计算机要执行任务(从读、写、开机和关机开始)就需要这个标准。
POSIX则是指一个UNIX的标准体系,或一个由来自不同公司的代表所组成的组织,希望按照一个共同的标准进行运作。对于程序员开发的新应用软件或新版本而言,标准是极其重要的。
从POSIX这样的系统调用(system call),尤其是重要的调用中,我可以获得一个操作系统应该具有哪些功能的清单;然后我就可以通过自己的方式在自己的系统中实现每一个功能。

3. Portability

Before discussing portability, distinguish system calls from library functions.

1. System Call

A system call is the interface to the operating system kernel, allowing user‑mode processes to interact with hardware.

2. Library Function

Library functions are packaged routines used by applications; they may be standard C library functions or compiler‑specific.

glibc is the open‑source C library on Linux, providing APIs that follow POSIX.

3. Difference between Library API and System Call

(1) Library functions belong to the language/application, while system calls belong to the kernel.

(2) Library functions run in user space, system calls run in kernel space; library calls have lower overhead.

(3) System calls are platform‑dependent, library functions are not.

4. Essence of Program Portability

Compilers generate object code and startup code; portability depends on the number of compilers and hardware/OS dependencies.

Code can be made portable using conditional compilation macros, e.g.:

#ifdef _WINDOWS_
    CreateThread(); // Windows thread creation
#else
    Pthread_create(); // Linux thread creation
#endif

Similarly for header inclusion:

#ifndef _WINDOWS_
    #include <windows.h>
#else
    #include <thread.h>
#endif

5. System Call Overhead

System calls incur performance cost due to mode switches; reducing the number of calls and doing more work per call improves efficiency.

4. Example

When an application calls printf(), the call flows through the C library to the kernel’s write() system call.

Some functions like strlen, strcat, memcpy do not invoke system calls.

Execution trace (using strace) shows the sequence of system calls:

用户态→系统调用→内核态→返回用户态

Note: running a program with strace reveals the function‑library call process.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

standardizationLinuxOperating SystemsUnixsystem callsPOSIXPortability
IT Services Circle
Written by

IT Services Circle

Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.