210 likes | 274 Views
Chapter 13. Processes. What is a process?. A process is a program in execution A process is created whenever an external command is executed Whenever the execution of the external command is completed, the process is terminated. CPU Scheduling.
E N D
Chapter 13 Processes
What is a process? • A process is a program in execution • A process is created whenever an external command is executed • Whenever the execution of the external command is completed, the process is terminated
CPU Scheduling • CPU scheduling is the process of assigning the CPU to different processes • CPU scheduling takes into consideration many factors: • Whether the process is interactive or batch • The priority of the different processes • Process state of readiness • Past behavior of process
Figure 13.3 Steps for execution of a binary program sort by a LINUX shell
Figure 13.3 Steps for execution of a binary program sort by a LINUX shell
Figure 13.4 Steps for execution of a shell script by a LINUX shell
Figure 13.5 Execution of commands under the child shells (also called subshells)
Process Attributes • The system keeps track of several process attributes • The description of the current processes including their attributes can be displayed using the ps command • Syntax • ps [options] • Option syntax varies with SYS V (-), BSD ( ), GNU (--)
ps Command Syntax ps [options] Option syntax varies with • SYS V (-l, -a, -N, -u ulist, …) • BSD ( l, a, U ulist, f, …) • GNU (--l, --a, …) • l long listing • a all processes (not just users) • N negate selection • U ulist info about other users’ processes • f ASCII art tree format
Process Control Commands • nice • kill • Running commands in the background using & • Suspending process using CTRL-Z • fg • bg • ps • top • pstree • jobs
Daemons • Daemons are system processes running in the background in order to handle a variety of system services • Daemon examples: • mail daemon • print daemon • internet daemon
Specifying Multiple Commandsin a Single Command Line • Several commands separated by “;” in a single command are executed sequentially • Several commands separated by “&” in a single command are executed in parallel
Forced Termination • Foreground processes can be terminated using CTRL-C • Background processes can be terminated by: • Using kill • Bringing them to the foreground then using CTRL-C
Process Hierarchy • The current process hierarchy can be displayed using the pstree command • The ulimit command can be used to determine the maximum number of simultaneous processes that can berun by the user