section4
section4
System
PRESENTED BY SALMA KISHK
Outline
process introduction
process management Linux
C APIs for process
C code examples
Process
a program in execution
Program is passive entity stored on disk (executable file);process is
active
Program becomes process when executable file loaded into
memory
Process in Memory
c process example
Address Space (Memory)
Process in Memory con’t
page table
Representation of a Process (inside kernel!)
Process State
ready : the process is loaded into the main
memory. The process here is ready to run and is
waiting to get the CPU time for its execution
more
A Tree of Processes in Linux
ps aux
details about all system process
ps -ef
details about all system process & parent
process is
Exambles
pstree
display a tree of processes
fg send to foreground
bg send to back ground
pg/fg ---> recent job
pg/fg ---> job name
pg/fg ----> job number
Two command to install c
pid > 0
int pid =
pid = 0
call fork()
create process with fork
#include <unistd.h> Fork()
pid > 0
int pid =
pid = 0
pid > 0
int pid =
pid = 0
output
main process
with
id1 = x
first fork()
child
id1 = 0
z
child process
main process
with
with
id1 = x
id1 = x
id2 = 0
second fork()
child
child
id1 = 0
id1 = 0
id2 = 0
id2 = y
x y
multi fork() in for loop
Any questions ?