Presentation is loading. Please wait.

Presentation is loading. Please wait.

Process Control. Module 11 Process Control ♦ Introduction ► A process is a running occurrence of a program, including all variables and other conditions.

Similar presentations


Presentation on theme: "Process Control. Module 11 Process Control ♦ Introduction ► A process is a running occurrence of a program, including all variables and other conditions."— Presentation transcript:

1 Process Control

2 Module 11 Process Control ♦ Introduction ► A process is a running occurrence of a program, including all variables and other conditions. It is an executing program. ► Each process contains a system wide unique process number (PID- Process Identification). ♦ Topics ► Identifying Process ► Managing Process ► Background Processing ► Putting Jobs in Background

3 Process Control ♦ The operating system will execute the processes by default and the user can also create a process. ♦ The process can be identified which is in execution along with its PID (process identification number). ♦ Process creation ♦ Processes are created with the fork system call (the operation of creating a new process is called forking). ► Example: vi Identifying Process Contd…

4 Process Control ♦ Viewing the process origin ► The pstree command is used to display the process origin. Identifying Process Contd…

5 Process Control Identifying Process ♦ Viewing the current process The ps command is one of the tools for visualizing processes. It displays the current working shell. Since ps command does not give detailed information about the process, the grep command in a pipe is used to select a particular process out of the list of all processes.

6 Process Control ♦ The bg command is used to check and move a job to background Managing Process Contd…

7 Process Control ♦ Example for foreground Managing Process Contd…

8 Process Control Managing Process ♦ Process Scheduling ► The Linux kernel uses a process scheduler to decide which process has to be executed first. It is done by using process priority. ♦ Scheduling Priorities ► Every process has a scheduling priority. The operating system determines the priority of a process based on nice value method. To calculate this priority is difficult, but users can affect the priority by setting the nice value. The niceness value is the number ranging from -20 (highest priority) to 19 (lowest priority) It has a default value of zero. Process with a high priority gets to run more often, while the low priority background tasks, run less frequently. Contd…

9 Process Control ♦ Priorities for programs ► The nice values of active processes can be viewed using the ps command with the –l or –f option for long output. ♦ Example for nice command: ► The nice command is used to modify the default niceness value. To set the niceness value to a different value, use the –n option: ♦ Example: Managing Process Contd…

10 Process Control Contd… ♦ Showing priorities of different process Managing Process

11 Process Control Contd… Managing Process ♦ Usage of top command ► The top program displays all the system and user’s process priorities running in all the terminals. The process running on your system is updated once in every five seconds. A process in the running state is highlighted.

12 Process Control Contd… Managing Process ♦ Altering priorities of running programs ► The users can reduce the priority of currently running jobs using the renice command. Only the superuser is permitted to move up the priority of currently running processes. ► Example of renice command

13 Process Control Contd… Managing Process ♦ Terminating the process ► The process is terminated when it receives a signal. ► There are multiple signals that the user can send to a process. ► The kill command is used to send a signal to a process. ► The command kill -l shows a list of signals which the user wants to terminate.

14 Process Control Contd… ♦ killall command will perform an orderly shutdown of the process. Managing Process

15 Process Control ♦ killing a process Managing Process

16 Process Control Background Processing ♦ A background process is the child of the process. ♦ It refers to processes that are run with a relatively low priority, require little or no input, and produce a minimum of output. ♦ The background is also used for long tasks that require massive amount of computation and thus CPU time. ♦ Daemon (Disk and execution Monitor) ♦ A daemon is a background process that is considered to run independently, with little or no user interference. ♦ Example: Apache web server http daemon (httpd)

17 Process Control Putting Jobs in Background ♦ The shell offers a feature called job control which allows easy handling of multiple processes. This mechanism switches processes between the foreground and the background. Using this system, programs can also be started in the background immediately. ♦ putting jobs in background ♦ jobs command is used to verify the background process Contd…

18 Process Control Putting Jobs in Background ♦ Suspending a process ► A process can be suspended temporarily without being killed. Suppose that ‘&’ symbol is missed out by mistake, use ^z and the process will be suspended. ► The process still exists but is idling. To resume the process in the background type the bg command (background).

19 Process Control Lab Exercise ♦ Create a process vi with filename and send the process to background and check background process ♦ Check the background running process and bring it to the foreground ♦ How to send running process to the background and bring it back to the foreground? ♦ Start a Process using find command with the priority of -18 ♦ Display and manage the priorities with the single command


Download ppt "Process Control. Module 11 Process Control ♦ Introduction ► A process is a running occurrence of a program, including all variables and other conditions."

Similar presentations


Ads by Google