0% found this document useful (0 votes)
25 views20 pages

CS3451 - Introduction To Operating Systems: Ii Year / Iv Semester

Uploaded by

revicse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views20 pages

CS3451 - Introduction To Operating Systems: Ii Year / Iv Semester

Uploaded by

revicse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

ARASU ENGINEERING

COLLEGE
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

CS3451 – INTRODUCTION TO
OPERATING SYSTEMS
II YEAR / IV SEMESTER
Anna University Syllabus, 2021
Regulation
Prepared by
Mrs. V. Revathy
Assistant
Professor/ CSE
Priority Scheduling
 A priority number (integer) is associated with
each process
 The CPU is allocated to the process with the
highest
priority (smallest highest
integer priority)
 Preemptive
 Nonpreemptive
 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
Example of Priority Scheduling
Process Burst Time Priority
P1 10 3
P2 1 1
P3 2 4
P4 1 5
P5 5 2
Gantt Chart

Average waiting time = 8.2


msec
CS3451-IOS/ V. REVATHY / AP-CSE /AEC
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
CS3451-IOS/ V. REVATHY / AP-CSE /AEC
Example of RR with Time Quantum = 4
Process Burst Time
P1 24
P2 3
P3 3
Gantt hart: P1 P P
2
P P
3
P 1
P 1 1 1
P1
0 4 7 10 30

c
14 18 22
26

Typically, higher average turnaround than SJF,


but better response
q should be large compared to context
switch time
q usually 10ms - 100ms, context switch < 10
usec
CS3451-IOS/ V. REVATHY / AP-CSE /AEC
Time Quantum and Context Switch Time

Turnaround Time Varies


With The Time
Quantum
Multilevel Queue
 Ready queue is partitioned into separate queues, eg:
 foreground (interactive)
 background (batch)
 Process permanently in a given queue
 Each queue has its own scheduling algorithm:
 foreground – RR
 background – FCFS
 Scheduling must be done between the queues:
 Fixedpriority scheduling; (i.e., serve all from
foreground then from background). Possibility of starvation.
 Time slice – each queue gets a certain amount of CPU time
which it can schedule amongst its processes i.e.80% to
 foreground in RR in
20% to background
FCFS CS3451-IOS/ V. REVATHY / AP-CSE /AEC
Multilevel Queue
Scheduling

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


Multilevel Feedback Queue
A process can move between the various queues;
aging can be implemented this way
Multilevel-feedback-queue scheduler defined by
the following parameters:
 number of queues
scheduling algorithms for each queue
method used to determine when to upgrade a
process
method used to determine when to demote a process
method used to determine which queue a process will
enter when that process needs service
CS3451-IOS/ V. REVATHY / AP-CSE /AEC
Example of Multilevel Feedback Queue
 Three queues:
 Q0 – RR with time quantum 8 ms
 Q1 – RR time quantum 16 ms
 Q2 – FCFS
 Scheduling
 A new job enters queue Q0 which is served FCFS
 When it gains CPU, job receives 8 milliseconds
 If it does not finish in 8 milliseconds, job is moved to
queue
Q1
 At Q1 job is again served FCFS and receives 16
additional milliseconds
queue
 If it still does not complete, it is preempted and
Q2
Thread Scheduling
 Distinction between user-level and kernel-level threads
 When threads supported, threads scheduled, not
processes
 Many-to-one and many-to-many models, thread library
schedules user-level threads to run on LWP
Known as process-contention scope (PCS) since
scheduling competition is within the process
Typically done via priority set by programmer
 Kernel thread scheduled onto available CPU is system-
contention scope (SCS) – competition among all threads
in system

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


Multiple-Processor
 CPU scheduling more complex when multiple CPUs are available
Scheduling
 Homogeneous processors within a multiprocessor
 Asymmetric multiprocessing – only one processor accesses the
system data structures, alleviating the need for data sharing
 Symmetric multiprocessing (SMP) – each processor is self-
scheduling, all processes in common ready queue, or each has its
own private queue of ready processes
 Currently, most common
 Processor affinity – process has affinity for processor on which it is
currently running
 soft affinity
 hard affinity
 Variations including processor sets
CS3451-IOS/ V. REVATHY / AP-CSE /AEC
Multiple Processor Scheduling – Load Balancing

If SMP, need to keep all CPUs loaded for


efficiency
Load balancing attempts to keep workload
evenly distributed
Push migration – periodic task checks load on
each processor, and if found pushes task from
overloaded CPU to other CPUs
Pull migration – idle processors pulls waiting task
from busy processor

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


Multicore Processors
Recent trend to place multiple
processor cores on same physical chip
Faster and consumes less power
Multiple threads per core also growing
Takes advantage of memory stall to make
progress on another thread while memory
retrieve happens

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


Multithreaded Multicore System

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


Real-Time CPU
Scheduling
 Can present obvious challenges
 Soft real-time systems – no
guarantee as to when critical
real- time process will be
scheduled
 Hard real-time systems – task
must be serviced by its deadline
 Two types of latencies affect
performance
 Interrupt latency – time from
arrival of interrupt to start of
routine that services interrupt
 Dispatch latency – time for schedule to take current process
off CPU and switch to another
CS3451-IOS/ V. REVATHY / AP-CSE /AEC
Real-Time CPU Scheduling
(Cont.)
 Conflict phase
dispatch
of latency:
 Preemption of
any
process
running kernel in
mode
Releas by low-
e process
priority
resources needed
by high-priorityof
processes

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


Priority-based
Scheduling
 For real-time scheduling, scheduler must support preemptive, priority-
based scheduling
 But only guarantees soft real-time
 For hard real-time must also provide ability to meet deadlines
 Processes have new characteristics: ones require CPU
periodic at
constant intervals
 Has processing time t, deadline d, period p
0 ≤ t ≤ d ≤ p
 Rate of periodic task is 1/p

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


Virtualization and
Scheduling
Virtualization software schedules multiple guests
onto CPU(s)
Each guest doing its own scheduling
Not knowing it doesn’t own the CPUs
Can result in poor response time
 Can effect time-of-day clocks in guests
Can undo good scheduling algorithm efforts
of guests

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


Thank You
CS3451-IOS/ V. REVATHY / AP-CSE /AEC

You might also like