|
|
HP-UX Process Management: White Paper > Chapter 1 Process ManagementWhat is a process? |
|
A process is a running program, managed by such system components as the scheduler and the memory management subsystem. Described most simply, a process is a container for a set of instructions that carry out the overall task of a program. A process consists of text (the code that the process runs), data (used by the code), and stack (temporary data storage for when the process is running). These and other elements are known as the process context.
Two stacks are associated with a process, kernel stack and user stack. The process uses the user stack when in user space and the kernel stack when in kernel space. Although processes appear to the user to run simultaneously, in fact a single processor is executing only one process at any given instant. A process's proc structure includes:
Processes maintain hierarchical, parent-child relationships. Every process has one parent, but a parent process can have many child processes. Processes can create processes, which in turn, can create more processes. A child process inherits its parent's environment (including environment variables, current working directory, open files). Also, all processes except system processes (such as init, pagedaemon, and sched (the "swapper")) belong to process groups, which are explained shortly. When a process is created, HP-UX assigns the process a unique integer number known as a process ID (PID). The HP-UX kernel identifies each process by its process ID when executing commands and system calls. A process also has a parent process ID (PPID), which is the PID of the parent process. You can see the PIDs and PPIDs of processes currently running on your system by using the ps command. In addition to the process ID, a process has other identification numbers:
Real user ID is an integer value that identifies the owner of the process -- that is, the user ID of the user who invoked the process. Real group ID is an integer value that identifies the group to which the user belongs. The real group ID is shared by all users who belong to the group. It allows members of the same group to share files, and to disallow access to users who do not belong to the group. The id command displays both integers and names associated with real user ID and real group ID. The /etc/passwd file assigns the real user ID and real group ID to the user at login. The effective user ID and effective group ID allow a process running a program to act as the program's owner while the program executes. The effective IDs are usually identical to the user's real IDs. However, the effective user ID and group ID can be set (setuid and setgid) individually to allow limited superuser capability, by making the effective IDs of the program's processes equal to the real IDs of the program's owner. The classic example is passwd, which allows limited ability to change /etc/passwd. The effective IDs are used to allow a user to access or modify a data file or to execute a program in a limited manner. When the effective user ID is zero, the user is allowed to execute system calls as superuser. The effective user and group IDs remain set until:
In a trusted system, each user has an audit ID that does not change, even when the user executes programs using a different effective user ID. The context of a process includes its component parts and kernel resources, as detailed in the following table. Note, however, that some of these elements are now defined in terms of threads. Table 1-1 Context of a process
|
|