POSIX and UNIX Support in Windows

Introduction

Microsoft Windows supports the execution of UNIX programs since Windows NT 4.0: the Windows support for UNIX started by providing POSIX compatibility and continued with the availability of the Windows Services for UNIX or Subsystem for UNIX-based Applications (SUA) provided by Windows Vista and Windows Server 2008 and by Windows 7 and Windows Server 2008 R2. This article will briefly describe the feature of these subsystems thus providing an overview of the evolution of the UNIX support in the Windows versions. With Windows 8.1 and Windows Server 2012 R2 SUA is no longer available.

Back to top

POSIX Subsystem

Microsoft POSIX subsystem is one of 3 subsystems of several operating systems from the Windows NT family (together with OS/2 and Windows subsystems). Microsoft Windows implements only the first version of the POSIX standards, namely POSIX.1. The official code of POSIX.1 is ISO/IEC 9945-1:1990 or IEEE standard 1003-1:1990. The subsystem was included because of 1980s US federal government's requirements listed in Federal Information Processing Standard (FIPS) 151-2. Versions Windows NT 3.5, Windows NT 3.51 and Windows NT 4 were certified as compliant with the FIPS 151-2. The runtime environment of the subsystem is provided by two files: psxss.exe and psxdll.dll. A POSIX application uses psxdll.dll to communicate with the subsystem while communicating with posix.exe to provide display capabilities on the Windows desktop. Because only the first version of POSIX (POSIX.1) is implemented, a POSIX application cannot create a thread or window, nor can it use RPC or socket. Instead of implementing the later versions of POSIX, Microsoft offers Windows Services for UNIX. Starting with Windows XP, the POSIX subsystem is not included as part of standard Windows distributions and has been replaced by Interix.
The Windows NT POSIX subsystem is designed to run POSIX applications and meets the requirements of POSIX.1. POSIX (Portable Operating System Interface for Computing Environments) is a set of standards being drafted by the Institute of Electrical and Electronic Engineers (IEEE). It defines various aspects of an operating system, including topics such as programming interface, security, networking and graphical interface. So far, only one of these standards, POSIX.1 (also called IEEE Standard 1003.1-1990), has made the transition from draft to final form and gained a base of customer acceptance. POSIX.1 defines C-language API calls between applications and the operating system. It is an API based on ideas drawn from the UNIX file system and process model. Because POSIX.1 addresses only API-level issues, most applications written to the POSIX.1 API must rely on non-POSIX operating system extensions to provide services such as security and networking. POSIX applications need certain file-system functionality, such as support for case-sensitive filenames and support for files with multiple names (or hard links). The new file system, NTFS, supports these POSIX requirements. Any POSIX application requiring access to file system resources must have access to an NTFS partition; POSIX applications that do not access file system resources can run on any supported file system.
POSIX.1 is a source-level standard: it does not provide any binary compatibility.

Back to top

File Systems

POSIX requires a certain amount of functionality from the file system, such as the ability for a file to have more than one name (or hard links) and case-sensitive file naming: neither FAT nor HPFS supports these features, which is another reason why a new file system was required for Windows NT.
NTFS supports both hard links and case-sensitive naming. If you want to run in a POSIX-conforming environment, you need at least one NTFS disk partition on your computer. You can run POSIX applications from any Windows NT file system. If the application does not need to access the file system, the application will run with no problems; however, if the application does require access to the file system, it might not behave correctly on a non-NTFS disk partition.

Back to top

Implementation

The POSIX subsystem is implemented in Windows NT as a protected server. POSIX applications communicate with the POSIX subsystem through a message-passing facility in the Executive known as a Local Procedure Call (LPC). Figure 1 depicts the POSIX Subsystem implementation.

Figure 1: POSIX subsystem implementation.

The POSIX subsystem and each POSIX application run in a protected address space that protects them from any other application that might be running on Windows NT. POSIX application are preemptively multitasked with respect to each other and with respect to other applications running in the system.

Back to top

Application Compliance to POSIX.1

POSIX.1 has four categories of compliance, ranging from very strict to very loose. Windows NT 4.0 supports strictly conforming POSIX.1 applications and ISO/IEC conforming POSIX.1 applications. Windows NT supports the latter by virtue of the fact that only 110 of the 149 functions of standard C are part of POSIX.1 and standard C is itself an ISO standard (ISO/IEC 9899).
The POSIX.1 categories of compliance are the following

  • a strictly conforming POSIX.1 application requires only the facilities described in the POSIX.1 standard and applicable language standards. This type of application accepts the following conditions:   
    • any behavior described in ISO/IEC 9945-1 as unspecified or implementation-defined;
    • symbolic constants;
    • any value in the range permitted in ISO/IEC 9945-1;
  • an ISO/IEC-conforming POSIX.1 application is one that uses only the facilities described in ISO/IEC 9945-1 and approved conforming language bindings for the ISO or IEC standard. This type of application must include a statement of conformance that documents all options and limit dependencies and all other ISO or IEC standards used. This level of conformance is not as strict as the previous one: it allows a POSIX.1 application to make use of other ISO or IEC standards, such as GKS and it allows POSIX.1 applications within this level to require options or limit values beyond the minimum;
  • a <National Body> conforming POSIX.1 application differs from an ISO/IEC-conforming POSIX.1 application in that this type of application may also use specific standards of a single ISO/IEC organization, such as ANSI or British Standards Institute (BSI). This type of application must include a statement of conformance that documents all options and limit dependencies and all other <National Body> standards used;
  • a conforming POSIX.1 application using extensions is an application that differs from a conforming POSIX.1 application only because it uses nonstandard facilities that are consistent with ISO/IEC 9945-1; such an application must fully document its requirements for these extended facilities. This is the lowest level of conformance: almost any C program could satisfy this with the appropriate documentation.

POSIX applications can be started from a Windows NT console window (command prompt), My Computer, the Windows NT Explorer, or by invocation from within another POSIX application.

Back to top

Files Used

As mentioned before, the POSIX subsystem uses three files: psxss.exe is the POSIX subsystem server, the main component of the subsystem; posix.exe is the POSIX console session manager, responsible for handling communications between POSIX and the Windows Executive; psxdll.dll is the POSIX dynamic library that a POSIX application can use to communicate with the POSIX server.
Figure 2 depicts the POSIX Subsystem files interaction.

Figure 2: the POSIX Subsystem files interaction.

Back to top

Disabling the POSIX Subsystem

There is little to gain by disabling the POSIX subsystem in Windows NT because POSIX is only started once a POSIX-based application is started. There are no memory savings or performance increases.
If you want to disable the POSIX subsystem, you can do so by opening the Registry Editor, going to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems subkey and deleting the POSIX value.

Back to top

Windows Services for UNIX

Windows Services for UNIX (SFU) or Subsystem for UNIX-based Applications (SUA) is a software package produced by Microsoft which provides a Unix subsystem and other parts of a full Unix environment on Windows NT and some of its immediate successor operating-systems. It was an extension and replacement of the minimal Microsoft POSIX subsystem from Windows NT. SFU 1.0 and 2.0 (NT 4.0 and Windows 2000) used the MKS Toolkit; starting with SFU 3.0 (Windows XP; 1999), SFU used the Interix subsystem, which was acquired by Microsoft in 1999 from US-based Softway Systems as part of an asset acquisition; these are available free from Microsoft as a download.
Windows Server 2003 R2 included SFU 3.5 (on Disk 2), and renamed it to Subsystem for UNIX-based Applications (SUA). In Windows Server 2008 and high-end versions of Windows Vista (Enterprise and Ultimate), a minimal SUA is included, but most of the utilities must again be downloaded from Microsoft's web site.
Like the Microsoft POSIX subsystem in Windows NT that it replaces, Interix is not an emulation of a Unix kernel, but rather an implementation of a user-mode subsystem running directly on top of the Windows NT kernel. Windows Services for Unix and Subsystem for Unix-based Applications provide header files and libraries that make it easier to recompile or port Unix applications for use on Windows; they do not make Unix binaries compatible with Windows binaries: it is best thought of as a distinct Unix-like platform.

Back to top

Community Resources

Blogs

TechNet Pages

Microsoft Knowledge Base Articles

Technical Articles


See Also

NOTE: this section provides links that are external to the TechNet Wiki.

Documents

  • ISO/IEC 9945-1:1990
    Information technology -- Portable Operating System Interface (POSIX) -- Part 1: System Application Program Interface (API) [C Language]

Books