Professional Documents
Culture Documents
Operating Systems: Computer Sciences Department
Operating Systems: Computer Sciences Department
Operating Systems
CS 340 T
Introduction
Chapter 2: Process-Concept
1. Process Concept
2. Process Scheduling
3. Inter-process Communication
3
Process Concept
4
OBJECTIVES:
5
Process Concept
=
( a program that is loaded into memory
and in execution)
6
Process Concept (cont..)
Program : is a collection of instruction in a code manner ,
which is sometimes known as the text section.
Program = passive entity
Process = Active entity
Process : is more general than program as it includes more
details such as :
o Textsection
o Program counter
o Process Stack
o Data section
o Current activity
o Heap
7
The Process (cont..)
contains temporary data (such as function
parameters, return addresses, and local
variables
9
Diagram of Process State
10
Process Control Block (PCB)
Each process is represented in the operating system by a
process control block (PCB)
11
Process Control Block (PCB) (cont..)
12
CPU Switch From Process to Process
Time
13
Process Scheduling
14
Process Scheduling
15
Process Scheduling
Scheduler: it is an operating system module that responsible
of selecting process(/es).
Short-term
scheduler
(CPU scheduler/
process scheduler)
Long-term
Schedulers scheduler
(job scheduler )
Medium Term
Scheduling
16
Process Scheduling Queues
17
Process Scheduling Queues (cont.)
19
Representation of Process Scheduling
20
Queuing diagram
Schedulers
21
Schedulers
22
Schedulers (Cont)
23
Schedulers (Cont)
If all processes are I/O bound If all processes are CPU bound
• the ready queue will almost • the I/O waiting queue will
always be empty, almost always be empty,
• the short-term scheduler will • devices will go unused….
have little to do… • (minimize devices utilization)
• .(minimize CPU utilization)
24
Schedulers (Cont)
1. Medium Term Scheduling
Sometimes it can be advantageous to remove processes
from RAM …….(swap out)
Later, the process can be reintroduced into RAM
…….(swap in), and its execution can be continued where it
left off.
This scheme is called swapping. ( done by medium-term
scheduler)
Swapping may be necessary to:
Improve the process mix
Or because a change in memory requirements has
exceeded available memory (i.e. memory is almost full)
25
Schedulers (Cont)
26
Context Switch
When CPU switches to another process, the system must save the state of
the old process and load the saved state for the new process via a context
switch
Context of a process represented in the PCB
Context-switch time is overhead; the system does no useful work while
switching
Time dependent on hardware support
27
Operation on Processes
OS provide mechanisms for
process creation,
process termination
28
Process Creation
Parent process create children processes, which, in turn
create other processes, forming a tree of processes
Generally, process identified and managed via a process
identifier (pid)
Resources sharing options
Parent and children share all resources
Children share subset of parent’s resources
Parent and child share no resources
Execution options
Parent and children execute concurrently
Parent waits until children terminate
29
Process Termination
Process executes last statement and then asks the
operating system to delete it.
Returns status value (integer) from child to parent
Process’ resources are deallocated by operating system
Parent may terminate the execution of children
processes. Some reasons for doing so:
Child has exceeded allocated resources
Task assigned to child is no longer required
The parent is exiting and the operating systems does not allow
a child to continue if its parent terminates
30
Interprocess Communication
31
Interprocess Communication
independent cooperating
Cannot affect or be affected by Can affect or be affected by the
the execution of another execution of another process
process.
32
Interprocess Communication
2. Computation speedup:
To make a particular task run faster, we must break it into
subtasks, each of which will be executing in parallel with the
others.
This can be achieved only if the computer has multiple
processing elements (e.g. CPUs).
33
Interprocess Communication
3. Modularity:
4. Convenience
An individual user may work on many tasks at the same
time.
34
Interprocess Communication (Cont.)
35
Interprocess Communication (Cont.)
36
Communications Models