OS Process 2
OS Process 2
Chapter : Processes
Process Concept
Process Scheduling
Operations on Processes
Process
Program: Passive entity
Process is instance of a program under executing
Process – a program in execution
– Active Entity b/c it has Program Counter
associated to it.
1. Process Creation
2. Process Termination
Process Creation
Parent process create children processes, which, in turn
create other processes, forming a tree of processes
The process which creates other process, is termed the
parent of the other process, while the created sub-
process is termed its child.
Each process is given an integer identifier, termed as
process identifier, or PID. The parent PID (PPID) is also
stored for each process.
Process Creation (Cont.)
Resource sharing
Parent and children share all resources
Children share subset of parent’s resources
Parent and child share no resources
Execution Sequence
Parent and children execute concurrently
Parent waits until children terminate
Process Creation (Cont.)
Address Space
Address space may refer to a range of either physical or virtual addresses
accessible to a processor or reserved for a process.
Child process is duplicate of parent process (same program
and data
Child process has new program loaded into it
UNIX examples
fork () system call creates new process
exec() system call used after a fork to replace the
process’ memory space with a new program
fork()
System call fork() is used to create processes.
Why?
Child has exceeded allocated resources
Task assigned to child is no longer required
If parent is exiting/Terminated
Some operating system do not allow child to continue if its
parent terminates
– All children terminated - cascading termination
Process Termination
Processes may also be terminated by the system for a variety
of reasons,
The inability of the system to deliver the necessary system
resources.
In response to a KILL command or other unhandled process
interrupts.
A parent may kill its children if the task assigned to them is
no longer needed.
If the parent does not exit, the system may or may not allow
the child to continue without a parent (orphaned processes
are generally inherited by init, which then proceeds to kill
them.)
Process Termination
When a process ends, all of its system resources are freed
up. The process termination status and execution times are
returned to the parent if the parent is waiting for the child to
terminate,
or eventually returned to init if the process already became an
orphan.
The processes which are trying to terminate but cannot do so
because their parent is not waiting for them are termed
zombies. These are eventually inherited by init process as
orphans and killed off.
MCQ
A parent process calling _____ system call will be suspended
until children processes terminate.
a) wait
b) fork
c) exit
d) exec
MCQ
a
MCQ
With _____________ only one process can execute at a time;
meanwhile all other process are waiting for the processor. With
______________ more than one process can be running
simultaneously each on a different processor.
a) Multiprocessing, Multiprogramming
b) Multiprogramming, Uniprocessing
c) Multiprogramming, Multiprocessing
d) Uniprogramming, Multiprocessing
MCQ
d
MCQ
In LINUX, each process is identified by its :
a) Process Control Block
b) Device Queue
c) Process Identifier
d) None of the the mentioned
MCQ
c
MCQ
In LINUX, the return value for the fork system call is _____ for
the child process and _____ for the parent process.
a) A Negative integer, Zero
b) Zero, A Negative integer
c) Zero, A nonzero integer
d) A nonzero integer, Zero
MCQ
c
MCQ
The child process can :
a) be a duplicate of the parent process
b) never be a duplicate of the parent process
c) cannot have another program loaded into it
d) never have another program loaded into it
MCQ
a
MCQ
aa