Vous êtes sur la page 1sur 17

1

Lahore Garrison University


CSC351-Operating System
Week-6 Lecture-11
Semester 5 Fall 2018

Prepared by:

Saman Abdi
2
Instructor Contact Details

 Name: Saman Abdi


 Course Instructor: CSC351- Operating System
 Credit Hours: 5
 Office Location: CS-Female Staff Room
 Email: saman.abdi@lgu.edu.pk
 Visiting Hours: Wednesday (9-11 am)
 Lab Work: Video Tutorials & Supervision by
Instructor

Lahore Garrison University


3
Course Objectives

 To learn the fundamentals of Operating Systems.


 To learn the mechanisms of OS to handle processes and
threads and their communication
 To learn the mechanisms involved in memory
management in contemporary OS.
 To gain knowledge on distributed operating
system concepts that includes architecture,
Mutual exclusion algorithms, deadlock detection
algorithms and agreement protocolsUnderstand
how to read C++ doc library documentation and
reuse library code.
 To learn programmatically to implement simple
OS mechanisms.
Lahore Garrison University
4
Course Contents

 Following contents will be covered throughout the semester


in week wise lectures:
 OS basics, OS types, system calls, process management,
inter process communication, communication in client
server systems, Thread concepts, thread types, thread
control block, thread designs, CPU scheduling, process
synchronization, bakery algorithm, hardware solutions to
synchronization, Problems of synchronization, deadlock
occurrence, prevention, avoidance recovery, Memory
management, virtual memory, page faults, replacement
algorithms, operating system security.

Lahore Garrison University


5
Text Book

 Operating system concepts by


Abraham Silberschatz, Galvin,
Gagne, 9th edition

Lahore Garrison University


6

►CPU scheduling
►Schedulers
►Dispatcher
Preamble (Past
lesson brief) ►FCFS
►SJF

Lahore Garrison University


7
Chapter 6

 CPU Scheduling

Lahore Garrison University


8
Example of Shortest-remaining-time-first

 Now we add the concepts of varying arrival times and preemption to the
analysis
ProcessA arri Arrival TimeT Burst Time
P1 0 8
P2 1 4
P3 2 9
P4 3 5
 Preemptive SJF Gantt Chart

P 1
P 2
P4 P1 P3
0 1 5 10 17 26

 Average waiting time = [(10-1)+(1-1)+(17-2)+5-3)]/4 = 26/4 = 6.5 msec


Lahore Garrison University
9
Round Robin (RR)

 Each process gets a small unit of CPU time (time


quantum q), usually 10-100 milliseconds. After this time
has elapsed, the process is preempted and added to the
end of the ready queue.
 If there are n processes in the ready queue and the time
quantum is q, then each process gets 1/n of the CPU time
in chunks of at most q time units at once. No process
waits more than (n-1)q time units.
 Timer interrupts every quantum to schedule next process
 Performance
 q large  FIFO
 q small  q must be large with respect to context switch,
otherwise overhead is too high
Lahore Garrison University
10
Example of RR with Time Quantum = 4

Process Burst Time


P1 24
P2 3
P3 3
 The Gantt chart is:

P 1
P 2
P 3
P 1
P 1
P 1
P 1
P1
0 4 7 10 14 18 22 26 30

 Typically, higher average turnaround than SJF, but better response


 q should be large compared to context switch time
 q usually 10ms to 100ms, context switch < 10 usec
Lahore Garrison University
11
Time Quantum and Context Switch Time

Lahore Garrison University


12
Turnaround Time Varies With The Time Quantum

80% of CPU bursts should


be shorter than q

Lahore Garrison University


13
Priority Schedulling

A priority number (integer) is associated with each process

The CPU is allocated to the process with the highest priority


(smallest integer  highest priority)
Preemptive
Non-preemptive

SJF is priority scheduling where priority is the inverse of predicted


next CPU burst time

Problem  Starvation – low priority processes may never execute

Solution  Aging – as time progresses increase the priority of the


process
Lahore Garrison University
14
Priority Scheduling

ProcessA arri Burst TimeT Priority


P1 10 3
P2 1 1
P3 2 4
P4 1 5
P5 5 2
Priority scheduling Gantt Chart

Average waiting time = 8.2 msec


Lahore Garrison University
15

Q&A

Lahore Garrison University


16
Reference

 To cover this topics , different reference material


has been used for consultation.
 Operating systems concept by Abraham
siberchatz edition 9
 Tutorialspoint.com
 Google.com

Lahore Garrison University


17

Thank you 

Lahore Garrison University

Vous aimerez peut-être aussi