Académique Documents
Professionnel Documents
Culture Documents
PROCESSES
1 Unix Processes
2 Determining Information about Current Processes
3 Foreground/Background Processes
4 Terminating a Process
1 Unix Processes
~1~
Process States:
Created Terminated
----------------------------------------------------------------------------------------------------
Running Main Memory
Waiting Blocked
----------------------------------------------------------------------------------------------------
Swapped out Swapped out
and Waiting and Blocked
Fig: The various process states with arrows indicating possible transitions between states
~2~
Important Process States:
1. Created: - When a process is first created, it occupies the "created" or "new"
state. In this state, the process awaits admission to the "ready" state.
2. Ready Or Running: - also called waiting or runnable. Process awaiting
execution on CPU. There may be more than one process waiting for CPU.
3. Waiting: - A process that is waiting for some event (such as I/O operation
completion or a signal).
4. Terminated Or Zombie:- process may be terminated, either from the
"running" state by completing its executing.
Background Processing
Processing that does not take place on the screen. Background processing enables
you to process data in the background while executing other functions in parallel
on the screen. Although background processes are not visible to the user, they have
the same priority as online processes
To background a process, type an & at the end of the command line. For
example, the command sleep waits a given number of seconds before
continuing. Type
% sleep 10
~3~
This will wait 10 seconds before returning the command prompt %. Until the
command prompt is returned, you can do nothing except wait.
The & runs the job in the background and returns the prompt straight away,
allowing to run other programs while waiting for that one to finish.
Back grounding is useful for jobs which will take a long time to complete.
Foreground Processing
A foreground process is different from a background process in two ways:
1. Some foreground processes show the user an interface, through which the
user can interact with the program.
2. The user must wait for one foreground process to complete before running
another one.
$ command1
The next prompt will not appear until command1 finishes running.
Sleep 1000
~4~
Listing Suspended and Background Processes
When a process is running, back grounded or suspended, it will be entered
onto a list along with a job number. Type
% jobs
An example of a job list:-
%kill %jobnumber
%sleep 100&
%jobs
~5~
If it is job number 4, type
% kill % 4
ps (process status)
processes can be killed by finding their process numbers (PIDs) and using kill
PID_number
%sleep 1000&
%ps
% kill 20077
and then type ps again to see if it has been removed from the list.
%kill -9 20077
~6~
References:
1. http://heather.cs.ucdavis.edu/~matloff/UnixAndC/Unix/Processes.pdf
2. Wikipedia
3. Ibm.com
4. Linux.about.com
~7~