Sunteți pe pagina 1din 27

Introduction

What is an operating system


bootstrap
different objectives of OS
functions of OS
OS as manager
Objectives of OS
Convenience.
Efficiency.
Ability to evolve.
Evolution of OS
Different generation of computers.
Serial processing.
Simple batch system
multi-programmed batch system, IBSYS
60.
Timesharing OS
Parallel systems, Distributed systems, Real
time systems, Embedded systems
Process
Program under execution. It is an dynamic
entity consisting of the sequence of events created
as a result of execution of instructions. Is has a
beginning, a life time and an end. It includes the
current activity as represented by PC, stack
containing temporary data (Parameter, return
address, temporary variables). The same code of
program can result in many processes. A program
may have several conditional branches, depending
on data, CPU may follow different paths in the
address space. The same program code can be
shared by more than one user at a time. This type of
memory sharing will result in different processes.
Process life cycle
Five state model
Scheduled

Admitted Running
New Ready

Interrupt
I/O or event exit
completion I/O or event wait

Wait Terminat
e
Process life cycle
Seven state model
Suspend
New
Admit Admit Scheduler
dispatch
Activate
Ready Running
Ready, Suspend
suspend Interrupt
exit
I/O or event
Event completion I/O or event
complete wait
Activate Terminat
Wait, Wait e
suspend Memory
release
Transitions
newready,suspend (process creation duty with blocked
process)
newready if the new process is of high priority
wait wait suspend, if no space for new process
readyready suspend, if the wait queues are empty
ready suspend ready, ready queue is empty
wait suspend ready suspend, event for what process
waited is completed
wait suspend wait, if the process is of high priority and
memory becomes available.(poor performance)
Running ready suspend, a high priority process
preempts the process and no memory available.
Process control block
The structure maintained by the operating system that
represents a process
Typical elements of PCB
Process identification
Process ID
Parent process ID
User identifier
Processor state information
User visible registers
Control registers
Stack pointers
PCB
Pointer Process state
Process ID
Program counter
Registers
Memory limits
List of open files



Process control block (contd.)
Process control information
Scheduling information
Process state
Priority
Scheduling related information
Event waiting
Data structuring
Pointers to other processes in queues
Inter process communication

Process control information


Process privileges
Memory management
Resource ownership and utilization
Schedulers

Long term
Controls degree of multiprogramming
Good mixture of I/O and CPU bound process
Short term
CPU scheduler
Medium term
swapping
CPU and I/O burst
CPU burst
I/O burst or wait
Process can be viewed as an alternating sequence of CPU
and I/O burst.
Starts and ends with CPU burst

CPU burst
I/O
CPU burst

I/O
CPU burst
Context switching
Executing a new process needs to save the current
state of the currently executing process, that
includes the contents of different registers.
It is a pure overhead to the system.
It is dependent on hardware.
DECSYSTEM-20 uses different set of registers. Contex
switching here is a simply the change of pointer to a
new set of registers.
If the no of process is high, then needs the saving in
memory
Scheduling criteria
CPU utilization
Throughput
Turnaround time
Waiting time
Response time
Category of scheduling algorithm
Preemptive
Non-preemptive
When to make scheduling decision

Running wait
Terminate
Running ready Only in Preemptive
Wait ready
Scheduling algorithms
First in first out (FIFO)
Shortest job first (SJF)
Shortest remaining time next(SRTN)
Highest response ration next(HRTN)
Round Robin (RR)
Priority Scheduling
Multilevel queue
Multilevel feedback queue
FIFO
Process P1 P2 P3 P4 P5
Arrival time 0 0 2 8 12
Length 10 9 5 5 4
P1 P2
2 8 12
P3 P4 P5

P1 P2 P3 P4 P5
10 19 24 29 33
0

Process P1 P2 P3 P4 P5 Average

Waiting time 0 10 17 16 17 12

Turnaround time 10 19 22 21 21 18.6


SJF
Process P1 P2 P3 P4 P5
Arrival time 0 0 2 8 12
Length 10 9 5 5 4
P1 P2
2 8 12
P3 P4 P5

P2 P3 P5 P4 P1
9 14 18 23 33
0

Process P1 P2 P3 P4 P5 Average

Waiting time 23 0 7 10 2 8.4

Turnaround time 33 9 12 15 6 15
SRTN
Process P1 P2 P3 P4 P5
Arrival time 0 00 22 88 12
12
12
67 55 155 444
Length 10 9
P1 P2
P3 P4 P5

P2 P3 P2 P4 P4 P5 P2 P1
0 2 7 8 12 13 17 23 33
Process P1 P2 P3 P4 P5 Average

Waiting time 23 5+9 0 0 1 7.6

Turnaround time 33 23 5 5 5 14.2


RR=(L+W)/L
HRRN
Process
Process P1P1 P2P2 P3P3 P4P4 P5P5
Arrival
Arrivaltime
time 0 0 00 22 8 888 12
1212
Length
Length 1010 99 55 5 555 4 44
RR
RR
RR 12.4 1 4.2
2.2
P1 P2 RR
RR 1.9 2.4 1.2 45.2
1.5
2 8 12
P3 P4 P5

P2 P3 P1 P4 P5
0 9 14 24 29 33

Process P1 P2 P3 P4 P5 Average

Waiting time 14 0 7 16 17 10.8

Turnaround time 24 9 12 21 21 17.4


Round Robin
Process P1 P2 P3 P4 P5
Arrival time 50 10
00 222 888 12
12
Length 510 499 555 555 44
P1P2 P P4 P5
3

P1 P2 P3 P1 P4 P2 P5
0 2 5 8 10 12 15 2 25 29 33
0

Process P1 P2 P3 P4 P5 Average

Waiting time 10 5+15 8 12 17 13.4

Turnaround time 20 29 13 17 21 20
Round Robin with Time slice 10 &2
P1 P2
2 8 12
P3 P4 P5

P1 P2 P3 P4 P5
10 19 24 29 33
0
With longer time slice RR will be converted to FIFO

P1 P2 P3 P1 P2 P3 P4 P1 P2 P5 P3 P4 P1 P2 P5 P4 P1 P2

With very short time slice in RR, considerable amount of time


will be wasted on Context Switching.
Problem
Draw the Gantt chart and find the average waiting time for the
following set of process, scheduled with --
1. Highest response ratio next algorithm
2. Round Robin algorithm with time slice 5.
P1 P2 P3 P4 P5 P6
Arrival time 0 4 6 10 12 15
Length 8 7 6 3 3 4
Priority Scheduling
Multilevel Queue Scheduling

Ready queue 1 Highest priority

Ready queue 2

Ready queue N Lowest priority


Multilevel Feedback Queue Scheduling
Different ready queues with priority, Processs priority is dynamic

Ready queue 1 If the process


If processs
cant complete
waiting time
within time
in a Q exceeds
Ready queue 2 slice of the Q,
the limit, then
then degrade
improve its
the priority of
priority.
Ready queue 3 the process.

Ready queue 3
Example
Process p1 p2 p3 p4 p5 p6 p7 p8
A/T 0 0 2 5 7 8 14 21
Priority 4 1 2 4 1 3 2 2
Len 18 3 6 20 6 10 9 10
AtAt
At time
At
Attime
time
53
59
61
68
time
time
(P11
13
7306815
39(time
40
51 31(timeis(time
23(time
is expires
expires
promoted)
promoted)
expires
expires for
for Pfor PP48Pis
6, for ,P5P7)promoted)
)6and P1 are promoted)
Q1(4,--)
Q1(4,--) P2(0,3,0)
Q1(4,--)
Q1(4,--)
Q1(4,--) P5(7,6,0)
Q2(8,10)
Q2(8,10)
Q2(8,10)
Q2(8,10)
Q2(8,10)
Q2(8,10) PPP
P68(59,2,0)
(51,2,0) (11,2,2)
3537(2,6,1)
(7,2,4),
(14,9,1)P5(11,6,0)
(7,2,0)
6 8(21,10,2)
(28,10,3)
P
Q3(16,20)
Q3(16,20)
Q3(16,20) P7P
Q3(16,20)
Q3(16,20)
Q3(16,20) 41(59,14,9)
P(23,1,16),P
Q3(16,20) PP(23,1,8),
666(8,10,5)
(30,18,10),P
(35,20,18),P
(51,7,10),
(35,20,16),P
(51,7,8),
P P P(59,14,0)
468(59,14,2)
(8,10,3)
(8,10,7)
P (31,2,9),
(39,2,14),
(30,18,9),P
(8,10,15),
(39,2,12),
P PP
P
4(35,20,5),P
(51,7,2)
(31,2,8),
(30,18,1),P
P (23,1,0) P
1(51,7,0) 6(39,2,1) 6(39,2,0)
(35,20,0),P
(31,2,0)
14 7 6 4 6 1 1 8
7 1 8 4

Q4(--,30)
Q4(--,30)
Q4(--,30) P (0,18,0)
PP1(0,18,3)
(0,18,13),
(0,18,7), PP (5,20,8)
(5,20,2)
Q4(--,30) 1 PP
Q4(--,30)
Q4(--,30)
Q4(--,30) (0,18,11),
(0,18,15),
(5,20,26)
P
4 111 (0,18,23), 4PP44(5,20,6)
4 (5,20,10)
4(5,20,18)
P2 P3 P5 P3 P5 P7 P8 P6 P7 P1 P8 P4 P6 P1 P4
0 3 7 11 13 15 23 31 39 40 51 53 59 61 68 82

S-ar putea să vă placă și