Lesson 3 - Information Technology Gate

Download Report

Transcript Lesson 3 - Information Technology Gate

An Introduction to processes
R Bigelow
A Unix Process
A process in Unix is simple a program
The Unix system is made up of a group
of processes all interacting with each
other.
Recall the Unix Philosophy ;
Write a program that does one thing
really well
The Linux Boot up Sequence
After the computer completes it POST
routine and start to boot. In a Linux
system the first thing that runs is grub .
Grub is a pre-boot operating system
that allow one to run multiple operating
systems on a single hard drive.
Boot Linux
If it is decided to load Linux lilo will
then start loading the Linux kernel.
(generally the kernel is call /vmlinuz or
/zImage or something similar) The
kernel is simple a file that contains
basic driver information about the
system. The kernel then spawns the init
process
init
All Unix systems start will a single
program init
init can be thought of as the great
grand parent to all other programs on
the system.
Every other process that runs does so
under init
The parent child relationship
In Unix every program that runs (with
the exception of init) has a parent
process that started it.
A sample Unix system
init
httpd
syslog
bash
inetd
bash
bash
pico
ls -la
The parent-Child Relationship
Child of init
and parent of
bash shells
init
httpd
syslog
bash
Child of inetd
and parent of
pico
pico
inetd
bash
bash
ls -la
Process ID Numbers
Every process must have a unique
identification number.
This number used as a tracking number
to keep track of CPU timeslot and
memory maps.
The administrator can use the PID
number to track whos running what
and to terminate processes.
Viewing current processes
The sequence of PID varies from Unix
version to Unix version but all have one
thing in common init is PID #1
To View a list of currently active
processes one would use the ps
command.
Background Vs Foreground
Suppose you are running a script and you
realize that you need to email something asap.
In Unix you are able to suspend most processes
to the background then work on another.
As well you can also have a process outputting
information in the background as you are
working on another in the foreground
Suspending and retuning to a
process
To suspsend a process simply hit ctrl-z.
This does not terminate the process like
ctrl-c does it simple disconnects your
standard input and standard output
from the program
To return to the process you would use
the jobs command.
The jobs command
This show you a list of all suspend
processes that you currently have.
IE ) jobs
[1]- Stopped
ping 127.0.0.1
[2]- Stopped
./bobo
foreground vs. background
The user may opt instead of just
returning to the program to have the
program run in the background.
What this means is that the user is
unable to affect the program (provide
input), but will still see the results of
the program on the screen.
Switching between the
foreground and background
fg <job number>
moves that job number into the foreground
bg <job number>
moves that process into the background
NOTE: It is possible to have multiple
processes in the background, but one can
only have one process in the foreground.
Stopping a process
To stop a process one would use the kill
command.
kill -<level> <PID>
or
killall program name
Kill levels
-1 Send the restart command to the
process (causes the program to re-read
startup files)
-9 Stop the process
-15 Terminate the process
Orphan processes
By killing the parent process this should kill all
children processes.
If the child process doesnt terminate along with
the parent it is referred to as an orphan.
Orphan process should not occur. This generally
means that the process has hung. However you
may still be able to kill the process.
Zombie Process
This is a process that has been sent the kill
signal, however for whatever reason it is
still running, and may be taking up
resources. Zombies may have been a
orphaned process that for whatever reason
is just not responding to the system.
The only way to get rid of a zombie is to
reboot.