Download presentation
Presentation is loading. Please wait.
1
Introduction What is an operating system bootstrap
different objectives of OS functions of OS OS as manager
2
Objectives of OS Convenience. Efficiency. Ability to evolve.
3
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
4
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.
5
Process life cycle Five state model Scheduled Admitted Interrupt
Running New Ready I/O or event wait exit I/O or event completion Terminate Wait
6
Process life cycle Seven state model Suspend New Admit Admit
Scheduler dispatch Activate Interrupt Running Ready Ready, suspend I/O or event wait Suspend exit I/O or event completion Event complete Terminate Activate Wait, suspend Wait Memory release
7
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.
8
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
9
PCB Process ID Registers Memory limits List of open files
Registers Memory limits List of open files Program counter Process state Pointer
10
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
11
Schedulers Long term Short term Medium term
Controls degree of multiprogramming Good mixture of I/O and CPU bound process Short term CPU scheduler Medium term swapping
12
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
13
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
14
Scheduling criteria CPU utilization Throughput Turnaround time
Waiting time Response time
15
Category of scheduling algorithm
Preemptive Non-preemptive
16
When to make scheduling decision
Running wait Terminate Running ready Wait ready Only in Preemptive
17
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
18
FIFO Process P1 P2 P3 P4 P5 Arrival time 0 0 2 8 12 Length 10 9 5 5 4
P3 2 P4 8 P5 12 P1 P2 P3 P4 P5 10 19 24 29 33 Process P1 P2 P3 P4 P5 Average Waiting time Turnaround time
19
SJF Process P1 P2 P3 P4 P5 Arrival time 0 0 2 8 12 Length 10 9 5 5 4
P3 2 P4 8 P5 12 P2 P3 P5 P4 P1 9 14 18 23 33 Process P1 P2 P3 P4 P5 Average Waiting time Turnaround time
20
SRTN Process P1 P2 P3 P4 P5 Arrival time 0 0 2 8 12 Length 10 9 5 5 4
P3 0 2 7 5 7 P3 P4 8 5 P1 33 P5 8 12 1 4 P4 13 12 4 P2 23 P5 17 8 P2 6 P2 2 12 P4 Process P1 P2 P3 P4 P5 Average Waiting time Turnaround time
21
HRRN RR=(L+W)/L P5 33 Process P1 P2 P3 P4 P5 Arrival time 0 0 2 8 12
Length Process P1 P2 P3 P4 P5 Arrival time Length P1 P2 P2 P3 2 P4 8 9 2 8 5 5 P4 29 P1 24 P3 P5 12 14 8 12 5 4 RR 1 1 RR 4.2 4 RR RR RR 5.2 Process P1 P2 P3 P4 P5 Average Waiting time Turnaround time
22
Round Robin Process P1 P2 P3 P4 P5 Arrival time 0 0 2 8 12
Length Process P1 P2 P3 P4 P5 Arrival time Length P1 P3 5 2 5 0 2 5 9 5 P2 P4 10 8 P1 20 P3 P5 15 12 8 12 5 4 P2 29 P1P2 P4 25 P5 33 Process P1 P2 P3 P4 P5 Average Waiting time Turnaround time
23
Round Robin with Time slice 10 &2
P1 P2 P4 P3 P5 P1 P2 2 8 12 10 19 24 29 33 With longer time slice RR will be converted to FIFO P1 P2 P3 P4 P5 With very short time slice in RR, considerable amount of time will be wasted on Context Switching.
24
Problem Draw the Gantt chart and find the average waiting time for the following set of process, scheduled with -- Highest response ratio next algorithm Round Robin algorithm with time slice 5. P1 P2 P3 P4 P5 P6 Arrival time Length
25
Multilevel Queue Scheduling
Priority Scheduling Multilevel Queue Scheduling Ready queue 1 Ready queue 2 Ready queue N Highest priority Lowest priority
26
Multilevel Feedback Queue Scheduling
Different ready queues with priority, Process’s priority is dynamic Ready queue 1 If the process can’t complete within time slice of the Q, then degrade the priority of the process. If process’s waiting time in a Q exceeds the limit, then improve its priority. Ready queue 2 Ready queue 3 Ready queue 3
27
Example At time 7 Q1(4,--) P5(7,6,0) Q2(8,10) P3(7,2,0) Q3(16,20)
Process p1 p2 p3 p4 p5 p6 p7 p8 A/T Priority Len At time 7 Q1(4,--) P5(7,6,0) Q2(8,10) P3(7,2,0) Q3(16,20) Q4(--,30) P1(0,18,7), P4(5,20,2) At time 3 Q1(4,--) Q2(8,10) P3(2,6,1) Q3(16,20) Q4(--,30) P1(0,18,3) At time 13 Q1(4,--) Q2(8,10) P5(11,2,2) Q3(16,20) P6(8,10,5) Q4(--,30) P1(0,18,13), P4(5,20,8) At time 11 (time expires for P5) Q1(4,--) Q2(8,10) P3(7,2,4), P5(11,6,0) Q3(16,20) P6(8,10,3) Q4(--,30) P1(0,18,11), P4(5,20,6) At time 0 Q1(4,--) P2(0,3,0) Q2(8,10) Q3(16,20) Q4(--,30) P1(0,18,0) At time 39(time expires for P6, P4 is promoted) Q1(4,--) Q2(8,10) Q3(16,20) P7(23,1,16),P1(30,18,9),P8(31,2,8), P4(35,20,0),P6(39,2,0) Q4(--,30) At time 51 (P8 is promoted) Q1(4,--) Q2(8,10) P8(51,2,0) Q3(16,20) P4(35,20,16),P6(39,2,12), P1(51,7,0) Q4(--,30) At time 40 Q1(4,--) Q2(8,10) Q3(16,20) P1(30,18,10),P8(31,2,9), P4(35,20,5),P6(39,2,1) Q4(--,30) At time 59 (P6 is promoted) Q1(4,--) Q2(8,10) P6(59,2,0) Q3(16,20) P1(51,7,8), P4(59,14,0) Q4(--,30) At time 53 Q1(4,--) Q2(8,10) Q3(16,20) P4(35,20,18),P6(39,2,14), P1(51,7,2) Q4(--,30) At time 61 Q1(4,--) Q2(8,10) Q3(16,20) P1(51,7,10), P4(59,14,2) Q4(--,30) At time 68 Q1(4,--) Q2(8,10) Q3(16,20) P4(59,14,9) Q4(--,30) At time 31(time expires for P8, P6and P1 are promoted) Q1(4,--) Q2(8,10) P6(28,10,3) Q3(16,20) P7(23,1,8), P1(30,18,1),P8(31,2,0) Q4(--,30) P4(5,20,26) At time 15 Q1(4,--) Q2(8,10) P7(14,9,1) Q3(16,20) P6(8,10,7) Q4(--,30) P1(0,18,15), P4(5,20,10) At time 23(time expires for P7) Q1(4,--) Q2(8,10) P8(21,10,2) Q3(16,20) P6(8,10,15), P7(23,1,0) Q4(--,30) P1(0,18,23), P4(5,20,18) P2 P3 P5 P7 P8 P6 P1 P4
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.