University Of Palestine Essential System Administration 3rd Edition Chapter 2 The Unix Way(Cont.)
Ch2 University Of Palestine 2.2 Processes • In simple terms, a process is a single executable program that is running in its own address space. • Commands on Unix systems, may be composed of many processes working together to perform a specific task. • Simple commands like ls are executed as a single process. • A compound command containing pipes will execute one process per pipe segment. • Unix processes come in several types. We'll look at the most common here:
Ch2 University Of Palestine 2.2 Processes (Cont.) • 2.2.1 Interactive Processes • Interactive processes are initiated from and controlled by a terminal session. • Interactive processes may run either in the foreground or the background. • Foreground processes remain attached to the terminal; For example, typing a Unix command and waiting for its output means running a foreground process. • Background processes Unlike with a foreground process, the shell does not have to wait for a background process to end before it can run more processes.
Ch2 University Of Palestine 2.2 Processes (Cont.) • 2.2.1 Interactive Processes (Cont.) • Job control allows a process to be moved between the foreground and the background. • For example, when a process is moved from the foreground to the background, the process is temporarily stopped, and terminal control returns to its parent process (usually a shell). • The background job may be resumed and continue executing unattached to the terminal session that launched it.
Ch2 University Of Palestine 2.2 Processes (Cont.) 2.2.1 Interactive Processes (Cont.) The following table reviews the ways to control foreground and background processes provided by most current shells
Ch2 University Of Palestine 2.2 Processes (Cont.) • 2.2.4 Process Attributes • Unix processes have many associated attributes. Some of the most important are: • Process ID (PID) : A unique identifying number used to refer to the process. • Parent process ID (PPID) : The PID of the process's parent process (the process that created it). • Nice number The process's scheduling priority, which is a number indicating its importance relative to other processes. • This needs to be distinguished from its actual execution priority, which is dynamically changed based on both the process's nice number and its recent CPU usage.
Ch2 University Of Palestine 2.2 Processes (Cont.) 2.2.4 Process Attributes (Cont.) TTY : The terminal (or pseudo-terminal) device associated with the process. Real and effective user ID (RUID, EUID) : process's real UID is the UID of the user who started it. Its effective UID is the UID that is used to determine the process's access to system resources (such as files and devices). Real and effective group ID (RGID, EGID):
Ch2 University Of Palestine 2.2 Processes (Cont.) 188.8.131.52 The life cycle of a process The following figure illustrates the phases of the process life cycle:
Ch2 University Of Palestine 2.2 Processes (Cont.) • 184.108.40.206 The relationship between commands and files • The Unix operating system does not distinguish between commands and files in the ways that some systems do. • Unix commands are executable files stored in one of several standard locations within the filesystem. • Access to commands is exactly equivalent to access to these files. By default, there is no other privilege mechanism.
Ch2 University Of Palestine 2.3 Devices • One of the strengths of Unix is that users don't need to worry about the specific characteristics of devices and device I/O very often. • Device files are characterized by their major and minor numbers , which allow the kernel to determine which device driver to use to access the device (via the major number), as well as its specific method of access (via the minor number). • Major and minor numbers appear in place of the file size in long directory listings.
Ch2 University Of Palestine 2.3 Devices (Cont.) For example, consider these device files related to the mouse from a Linux system: $ cd /dev; ls -l *mouse crw-rw-r-- 1 root root 10, 10 Jan 19 03:36 adbmouse crw-rw-r-- 1 root root 10, 4 Jan 19 03:35 amigamouse crw-rw-r-- 1 root root 10, 5 Jan 19 03:35 atarimouse crw-rw-r-- 1 root root 10, 8 Jan 19 03:35 smouse crw-rw-r-- 1 root root 10, 6 Jan 19 03:35 sunmouse crw-rw-r-- 1 root root 13, 32 Jan 19 03:36 usbmouse • The major number for all but the last special file is 10; only the minor number differs for these devices. • Thus, all of these mouse device variations are handled by the same device driver. • The final item, corresponding to a USB mouse, has a different major number, indicating that a different device driver is used.
Ch2 University Of Palestine 2.3 Devices (Cont.) • Device files are created with the mknod command. • t takes the desired device name and major and minor numbers as its arguments. • Many systems provide a script named MAKEDEV (located in /dev), which is an easy-to-use interface to mknod.