Processes in the UNIX Shell - Data about processes
(Page 2 of 4 )
One of the most important tasks of the operating system is to make this switch from one process to another as effective as possible. On the road to achieving this, three tasks must be handled correctly: creating the correct time slices for multitasking, offering multi-user support and prioritizing processes. The programs start from the shell. However, the proper starting section is always handled by the kernel.
Due to this, the kernel creates a data structure containing some specific information. There is a protected memory segment for the process. There are at least three opened files at start time: the standard input, output and error files. When we start a program from a terminal, the process is linked to the terminal, and these three files also are linked to the terminal's I/Os.
The process will also get the environment variables as pairs of name value. Additionally, the process will have the processed command line arguments. The "processed" nature of the arguments means that the shell has already replaced meta-characters. Finally, each process will be assigned an integer number symbolizing its priority. A high value gives a higher chance for this process to be chosen as the one to use the CPU when it needs it.
The creation of a new process is fast and easy, using only minimal resources under UNIX. Due to this, the approach to solving larger and more complicated processes is to link together smaller ones. While the processes are not always running, they can have a couple of different states, as you can see below:
Name of status
PS command character
What it does
Running
R
Here we enter those processes that are currently running or just waiting for the processor to finish another task.
Interruptible sleep
S
The process is waiting for some event or input and can be interrupted by a signal. This is the case when we send the program to sleep using the sleep command or when it is waiting for some input to be entered by us.
Uninterruptible sleep
D
This is very similar to interruptible sleep, with the difference being that now the process cannot be interrupted by a signal. This is the case when the process is sending data to the printer or waiting for some I/O operation where the data must be sent/received in one piece.
Stooped/Traced
T
A process that is in this state is suspended and does nothing. This is the case if you press the Ctrl+Z combination and throw the program into the background.