Data Expedition, Inc.

Move Data Faster

Seth Noble

Seth Noble
Unix Tips
The Kernel
Manual Pages
Backing Up
HD Recovery

The Kernel

The Virtual Machine

The purpose of any operating system is to manage the resources of the hardware.  Resources include the central processing unit, random access memory, disk space, network communication, graphics display, and many other features.

UNIX is a multi-tasking OS, which means that there may be many programs and people using the same machine at the same time.  Thus the UNIX system must divide the machine's resources between all of these people and processes.  It does this using the concept of a virtual machine.

Under this paradigm, each program is given the illusion that it is running all by itself on its own computer.  The core of the operating system that is responsible for maintaining this illusion is called the kernel.  A collection of resources associated with a specific virtual machine (a program, data, input/output, etc.) is called a process.

Here is an example list of processes running on a SunOS 4.1.3_U1 machine. The meaning of the various data fields will be explained later.

Interacting with the system

Most programs need to do more than just manipulate data within their virtual machine.  Interacting with a user, reading or writing files, or asking for more memory all require the program to interact with the rest of the system.

Part of the kernel consists of a collection of low level procedures through which processes can access resources.  These procedures are called system calls and they are the primary means for a program to interact with other parts of the system.  System calls are listed in section 2 of the manual pages.  Any time that a program wishes to do anything beyond its own process environment, it must use system calls.

To see what system calls are made by a program, you can run it using the trace command (strace under linux or truss under Solaris 2.x). For example, try "trace ls" to see all of the calls needed to display a list of files.

Because they form the lowest level of interaction, system calls are very simplistic and generic.  It would be very tedious to have to write all of your programs using only system calls.  Thus procedures and functions for the most common tasks have already been written and stored in code libraries.

Libraries are collections of routines which provide common functions at an arbitrary level of complexity.  Some library routines perform common computing tasks such as sorting or converting letters to numbers.  Others act as more sophisticated interfaces to system calls.

For example, the C library routine "printf" is a complex output procedure which formats and outputs data.  It takes in many different kinds of data, converts it into readable text, and formats it.  Then it uses the system call "write" to actually send the data to the user.  Library functions are listed in section 3 of the manual pages.

The important difference between system calls and library functions is that system calls go outside your program and interact with the kernel and the rest of the system while library functions are subroutines that become a part of your program's virtual machine.


Unix allows many programs to run simultaneously by giving each one the illusion that it exists on its own private virtual-machine.  A process is a program, its data, and its virtual-machine constructs.  Processes can only access resources outside their virtual-machine by way of system calls.  System calls execute instructions that are part of the kernel, the core of the operating system.  Library calls execute prepackaged procedures that are incorporated into the calling process' virtual-machine.  Library calls which need resources from the operating system, must also use system calls.