UNIX process management separates the creation of processes and the running of a new program into two distinct operations.
1. The fork system call creates a new process.
2. A new program is run after a call to execve.
Under UNIX, a process encompasses all the information that the operating system must maintain t track the context of a single execution of a single program.
Under Linux, process properties fall into three groups: the processís identity, environment, and context.
Process ID (PID). The unique identifier for the process; used to specify processes to the operating system when an application makes a system call to signal, modify, or wait for another process.
Credentials. Each process must have an associated user ID and one or more group IDs that determine the processís rights to access system resources and files.
Personality. Not traditionally found on UNIX systems, but under Linux each process has an associated personality identifier that can slightly modify the semantics of certain system calls.
Used primarily by emulation libraries to request that system calls be compatible with certain specific flavors of UNIX.
The processís environment is inherited from its parent, and is composed of two null- terminated vectors:
1. The argument vector lists the command-line arguments used to invoke the running
program; conventionally starts with the name of the program itself
2. The environment vector is a list of ďNAME=VALUEĒ pairs that associates named
environment variables with arbitrary textual values.
Passing environment variables among processes and inheriting variables by a processís children are flexible means of passing information to components of the user mode
The environment-variable mechanism provides a customization of the operating system that can be set on a per-process basis, rather than being configured for the system as a whole.
The (constantly changing) state of a running program at any point in time.
The scheduling context is the most important part of the process context; it is the information that the scheduler needs to suspend and restart the process.
The kernel maintains accounting information about the resources currently being consumed by each process, and the total resources consumed by the process in its lifetime so far.
The file table is an array of pointers to kernel file structures. When making file I/O system calls, processes refer to files by their index into this table.
Whereas the file table lists the existing open files, the file-system context applies to requests to open new files. The current root and default directories to be used for new file searches are stored here.
The signal-handler table defines the routine in the processís address space to be called when specific signals arrive.
The virtual-memory context of a process describes the full contents of the its private address space.
Processes and Threads
Linux uses the same internal representation for processes and threads; a thread is simply a new process that happens to share the same address space as its parent.
A distinction is only made when a new thread is created by the clone system call.
1. fork creates a new process with its own entirely new process context
2. clone creates a new process with its own identity, but that is allowed to share the data
structures of its parent
Using clone gives an application fine-grained control over exactly what is shared between two threads.