Docsity

Scheduling - Advanced Operating System - Lecture Slides, Slides of Computer Science

Toggle sidebar
bg1
Scheduling
COMP755 Advanced OS 1
Scheduling
COMP450 Operating Systems
Goals of Scheduling
• User Oriented
– minimize response time (interactive)
– minimize Turnaround time (batch jobs)
– Meet deadlines
• System Oriented
– Predictable
– maximize Throughput
– Processor Utilization
–Fair
– Enforce priorities
– Balance resources
– Balance user groups
Levels of Scheduling
• Long Term scheduling
• Medium Term scheduling
• Short Term scheduling
• I/O scheduling
Long-term scheduling
• Only relevant for systems that have a
backlog of batch jobs to run
• Deals with creating a new process
• Controls the degree of multiprogramming
• Interactive systems tend to accept users
unless the system is swamped
• The more processes, the smaller
percentage of time each process is
executed
This is all we are going to say about long-term scheduling
Medium-term scheduling
• The decision to add to the number of
processes that are partially or fully in main
memory
• Deals with swapping processes in and out
• A swapped out process cannot be executed
until it is swapped back into RAM
Medium-term scheduling will be discussed when we talk about
memory management.
Short-Term Scheduling
• Determines which process is going to execute
next
• The short term scheduler is known as the
dispatcher
• Is invoked on an event that may lead to choosing
another process for execution:
– clock interrupts
– I/O interrupts
– operating system calls and traps
– signals
Short Term Scheduling is the subject of this chapter
Docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Scheduling - Advanced Operating System - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

COMP450 Operating SystemsScheduling ••^ User OrientedSystem Oriented– minimize response time (interactive)– minimize Turnaround time (batch jobs)– Meet deadlines– Predictable– maximize ThroughputGoals of Scheduling

– Processor Utilization– Fair– Enforce priorities– Balance resources– Balance user groups

• Long Term scheduling• Medium Term schedulingLevels of Scheduling

• Short Term scheduling• I/O scheduling

• Only relevant for systems that have a• Deals with creating a new processbacklog of batch jobs to runLong-term scheduling

• Controls the degree of multiprogramming• Interactive systems tend to accept users• The more processes, the smallerunless the system is swamped

This is all we are going to say about long-term schedulingpercentage of time each process isexecuted

• The decision to add to the number ofprocesses that are partially or fully in mainmemoryMedium-term scheduling

• Deals with swapping processes in and out• A swapped out process cannot be executeduntil it is swapped back into RAM

Medium-term scheduling will be discussed when we talk aboutmemory management.

• • Determines which process is going to executenextThe short term scheduler is known as thedispatcherShort-Term Scheduling

• Is invoked on an event that may lead to choosinganother process for execution:– clock interrupts– I/O interrupts– operating system calls and traps

Short Term Scheduling is the subject of this chapter– signals

Classification of Scheduling Activity

  • •• Long-term: which process to admitMedium-term: which process to swap in or outShort-term: which ready process to execute next
    • Non-preemptive^ Types of Dispatch Algorithms– Once the thread is started, it continues to
      • May cause one thread to monopolize the– Useful for real-time systemsrun until it voluntarily gives up control.system.
    • Preemptive– The dispatcher may select another thread– Most systems are preemptive.to run after a while.
  • FCFS• Round robinDispatcher Algorithms
  • Feedback queues• Priority• Shortest Job First• Shortest Process Next (shortest estimated
  • Real time schedulingCPU burst)
  • Each algorithm selects a thread from the• None of the scheduling algorithms willready list and runs it.Common Elements
  • The CPU can execute in parallel with I/O.• When a program is waiting for I/O toallow the processor to be idle if there is athread to run.
  • If there is only one thread on the ready list,complete, another thread can run.it doesn’t matter what algorithm you use.
  • Average time to completionScheduling AlgorithmEvaluation
  • Average total wait time• CPU utilization– minimize– minimize
  • maximize
  • Scheduler will always choose a process ofhigher priority over one of lower priorityPriority Scheduling
  • Have multiple ready queues to represent• May be preemptive or non-preemptive• Lower-priority may suffer starvationeach level of priority
  • allow a process to change its priority basedon its age or execution history
  • The dispatcher runs threads in the shortqueue in the FCFS order. As long asFeedback Queues
  • If a thread from the short queue uses all ofthere are threads in the short queue, theyare executed.its time quantum without relinquishing the

CPU, it is moved to the medium queue.

  • Threads in the medium queue areexecuted only when the short queue isFeedback Queues
  • Threads in the long queue are executedempty.only when the short and medium queuesare empty.

Feedback Queue (^) • Threads that do lots of I/O and very littleprocessing will be in the short queue.Feedback Analysis

  • Threads using the CPU for longer periodsThey will get the CPU ahead of CPUbound threads.will run for longer time quantums to reduce
  • CPU bound threads run only when therethe number of context switches.are no other threads to run.
  • Imagine your program and my program• If each program has one thread, then a fairare competing for the CPU.Fair Share Scheduling
  • Assume my program creates two morescheduling algorithm will give each thread50% of the available time.threads for a total of three. If each thread

gets an equal share of the CPU, myprogram gets 75% of the CPU.

Prioritized, Shortest ProcessNext, Multilevel FeedbackQueue Algorithm

  • The best of the described algorithms canbe combined to create a schedulingalgorithm sure to please everyone.

A Dr. Williams original.

  • Each thread is assigned a priority number.• When a thread uses its time quantum, thepriority number is lowered.PSPNMFQ Algorithm
  • When a thread is blocked, its priority• If a thread hasn’t been executed for a while,number is raised.its priority number is increased.
  • The highest priority numbered thread is• Time quantum length is inverselyselected.proportional to priority.
    • • A (^) Assume no overlap of I/O and processing.All I/O requests take 3 units of time. starts at 0 priority lowExample Programs 2 I/O 10 I/O 1 I/O 1 B 1 I/O 1 I/O 1 I/O 1 I/O 1 I/O 1 I/O 1 I/O 1 C 4 I/O 1 I/O 4 I/O 1 I/O 4 I/O 1 starts at 1 priority mediumstarts at 2 priority high D 2 I/O 1 I/O 6 I/O 1 I/O 4 I/O 1 starts at 3 priority medium AABXCXXCXXCXCDXDXXXAXAXAAAFCFSAAAAABXCXXDXXXXXXAXXBXXCXXCXXCXCDXDXDXDD D

A C XA2 I/O 10 I/O 1 I/O 14 I/O 1 I/O 4 I/O 1 I/O 4 I/O 1XBXCXDXXXXXXXBXCXCXCX CDXDXDXD BD XB XCX1 I/O 1 I/O 1 I/O 1 I/O 1 I/O 1 I/O 1 I/O 12 I/O 1 I/O 6 I/O 1 I/O 4 I/O 1XXDXBXXXB

Round Robin ABCXDXXABXCXXDXXXXAXBXCXDXXXAXBXCXDXXXXAXBCXDXXXXAXBCXDXXABCXDXXABC DAC

A C DX 2 I/O 10 I/O 1 I/O 14 I/O 1 I/O 4 I/O 1 I/O 4 I/O 1XXAXXAXCDXXXAXXXXCXDXA CXDXCXD A BD C 1 I/O 1 I/O 1 I/O 1 I/O 1 I/O 1 I/O 1 I/O 12 I/O 1 I/O 6 I/O 1 I/O 4 I/O 1DXXXXXXCD

  • Average time to completion– FCFS= 35 + 57 + 50 + 52 = 48.5– RR= 49 + 30 + 54 + 55 = 47Evaluation
  • Processor Utilization• Context Switches– FCFS = 52/57 = 91.2%– RR = 52/55 = 94.
    • FCFS = 27– RR = 53
      • There are many different types ofcomputers with multiple processors. TheMultiprocessors
      • All of the CPUs in an SMP system aremost common system in use today is the^ S identical and can address all of the RAMymmetric^ M ulti P rocessor (SMP).