Processes in Unix-7
Processes in Unix-7
A program/command when executed, a special instance is provided by the system to the process.
This instance consists of all the services/resources that may be utilized by the process under execution.
Used up pid’s can be used in again for a newer process since all the possible combinations are
used.
At any point of time, no two processes with the same pid exist in the system because it is the pid
that Unix uses to track each process.
Initializing a process
A process can be run in two ways:
Method 1: Foreground Process : Every process when started runs in foreground by default, receives
input from the keyboard, and sends output to the screen.
When issuing pwd command
$pwd
When a command/process is running in the foreground and is taking a lot of time, no other processes
can be run or started because the prompt would not be available until the program finishes processing
and comes out.
Method 2: Background Process: It runs in the background without keyboard input and waits till
keyboard input is required. Thus, other processes can be done in parallel with the process running in the
background since they do not have to wait for the previous process to be completed.
Adding & along with the command starts it as a background process .
$ pwd &
Since pwd does not want any input from the keyboard, it goes to the stop state until moved to the
foreground and given any data input. Thus, on pressing Enter:
Output:
Top Command
We can use top command to see processes with consumed resources like memory and cpu utilization.
use 'q' to come out of top command.
Killing a Process
Suppose the terminal has hung due to certain reasons which can be some indefinite loops running in
your system or too many processes running in background.Hence we kill that process by using their
processed.