ITFN 2601 Introduction to Operating Systems - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

ITFN 2601 Introduction to Operating Systems

Description:

A process is an executing Program. Multiprogramming ... Each Process must maintain it's own PCB ... The amount of time the job is ready (runnable but not running) ... – PowerPoint PPT presentation

Number of Views:84
Avg rating:3.0/5.0
Slides: 35
Provided by: kahunaC
Category:

less

Transcript and Presenter's Notes

Title: ITFN 2601 Introduction to Operating Systems


1
ITFN 2601Introduction to Operating Systems
  • Process Scheduling

2
Agenda
  • Scheduling
  • Batch
  • Interactive
  • Real-Time
  • Threads

3
Processes
  • A process is an executing Program
  • Multiprogramming
  • Consist of Program, input, output and a state

4
Why Processes?
  • Separation of Tasks
  • Pseudo-Parallel Execution
  • One Job, One Process

5
Process Creation
  • System Initialization
  • System call by running process
  • User request to create new process
  • Initiation of batch job

6
Process Termination
  • Normal Exit
  • Error Exit
  • Fatal Error
  • Killed by another process

7
Process States
  • Running
  • Ready
  • Blocked

8
Scheduling
  • Process Conditions
  • Processor Bound
  • I/O Bound
  • Scheduling how?
  • Pre-emptive
  • Non-pre-emptive

9
Process Internals
  • States
  • Running
  • Ready
  • Blocking
  • Process Control Block
  • State
  • Registers Memory
  • PC, SP, Files

Running
Blocked
Ready
10
Process Control
  • Each Process must maintain its own PCB
  • Information that Multiple Processes may use is
    duplicated

11
Scheduling When
  • New Process is Created
  • Parent process
  • Child process
  • Process Exits
  • When a process Blocks
  • I/O Interrupt occurs
  • Clock Interrupts
  • Non preemptive
  • Preemptive

12
Objectives of a Good Scheduling Policy
  • Fairness
  • Efficiency
  • Low response time (important for interactive
    jobs)
  • Low turnaround time (important for batch jobs)
  • High throughput

13
Scheduling
  • Throughput.
  • The amount of useful work accomplished per unit
    time. This depends, of course, on what
    constitutes useful work.'' One common measure
    of throughput is jobs/minute (or second, or hour,
    depending on the kinds of job).
  • Utilization.
  • For each device, the utilization of a device is
    the fraction of time the device is busy. A good
    scheduling algorithm keeps all the devices
    (CPU's, disk drives, etc.) busy most of the time.

14
Scheduling
  • Turnaround.
  • The length of time between when the job arrives
    in the system and when it finally finishes.
  • Response Time.
  • The length of time between when the job arrives
    in the system and when it starts to produce
    output. For interactive jobs, response time might
    be more important than turnaround.
  • Waiting Time.
  • The amount of time the job is ready (runnable
    but not running). This is a better measure of
    scheduling quality than turnaround, since the
    scheduler has no control of the amount of time
    the process spends computing or blocked waiting
    for I/O.

15
Preemption
  • Needs a clock interrupt (or equivalent)
  • Needed to guarantee fairness
  • Found in all modern general purpose operating
    systems
  • Without preemption, the system implements run
    to completion (or yield)''

16
First-Come-First-Served
  • The simplest possible scheduling discipline is
    called First-come, first-served (FCFS). The ready
    list is a simple queue (first-in/first-out). The
    scheduler simply runs the first job on the queue
    until it blocks, then it runs the new first job,
    and so on. When a job becomes ready, it is simply
    added to the end of the queue

17
FCFS
  • Main advantage of FCFS is that it is easy to
    write and understand
  • No starvation
  • If one process gets into an infinite loop, it
    will run forever and shut out all the others.
  • FCFS tends to excessively favor long bursts.
    CPU-bound processes

18
Shortest-job-first (SJF)
  • Whenever the CPU has to choose a burst to run, it
    chooses the shortest one
  • Non-preemptive policy
  • preemptive version of the SJF, called
    shortest-remaining-time-first (SRTF).
  • Starvation is possible

19
Three-Level Scheduling
  • Admission Scheduler which jobs to admit to the
    system
  • Memory Scheduler Which processes are kept in
    memory and which on disk
  • CPU Scheduler Pick ready process to run

20
Round-Robin
  • Round-robin (RR). RR keeps all the burst in a
    queue and runs the first one, like FCFS. But
    after a length of time q (called a quantum), if
    the current burst hasn't completed, it is moved
    to the tail of the queue and the next burst is
    started.

21
Round Robin
  • An important preemptive policy
  • Essentially the preemptive version of FCFS
  • The key parameter is the quantum size q
  • When a process is put into the running state a
    timer is set to q.
  • If the timer goes off and the process is still
    running, the OS preempts the process.
  • This process is moved to the ready state (the
    preempt arc in the diagram.
  • The next job in the ready list (normally a queue)
    is selected to run

22
Round Robin
  • As q gets large, RR approaches FCFS
  • As q gets small, RR approaches PS
  • What q should we choose
  • Tradeoff
  • Small q makes system more responsive
  • Large q makes system more efficient since less
    switching

23
Round Robin, Example
24
Priority Scheduling
  • Always to run the highest priority burst
  • preemptive or non-preemptive
  • Priorities can be assigned externally to
    processes based on their importance
  • Assigned (and changed) dynamically

25
Other Interactive Scheduling
  • Multiple Queues
  • Shortest Process Next
  • Guaranteed Scheduling
  • Lottery Scheduling
  • Fair-Share Scheduling

26
Scheduling Algorithms(Interactive, cont)
  • Multi-Quantized
  • Response time proportionate to quanta
  • More bookkeeping
  • Shortest Next
  • Estimation of Job length
  • Unfair for large jobs
  • Fast response for small jobs

27
Scheduling Algorithms(Interactive, cont)
  • Guaranteed Scheduling
  • Lottery Scheduling
  • Alotted time proportional to Job Size/Importance
  • Sharing
  • Fair by user, not necessarily fair by job
  • Responses become disproportionate

28
Scheduler Goals
  • Generic Goals
  • Fairness of processor allocation
  • Enforcement of Scheduling Policies
  • Balance of utilization
  • Batch-based Goals
  • Maximize throughput of jobs
  • Minimize turnaround on jobs

29
Scheduler Goals II
  • Interactive System Goals
  • Minimize response time for user I/O
  • User expectations should be met
  • Real-time System Goals
  • Deadlines must be met for Process Completion
  • System Performance must be predictable

30
Scheduling Algorithms(Batch)
  • FIFO (First In First Out) NON-PREEMPTIVE
  • Fairest
  • Low throughput
  • High Turnaround
  • Shortest First NON-PREEMPTIVE
  • High Throughput
  • Low Turnaround
  • Unfair for Large Jobs

31
Scheduling Algorithms(Batch, cont)
  • Shortest Remaining - PREEMPTIVE
  • High Turnaround on Long Jobs
  • Unfair for Large Jobs
  • Multi-Scheduling (CPU or Memory Limited)
  • HIGH Turnaround (disk swaps)
  • Throughput highly variable, probably low
  • Fairness highly variable

32
Scheduling Algorithms(Interactive)
  • Round Robin - PREEMPTIVE
  • Fairest overall
  • Response time variable but finite
  • Priority Scheduling - PREEMPTIVE
  • Fair
  • More Fair for users with higher priorities
  • Response time inverse to priority
  • Windows/Unix typically implement this

33
Scheduler Mechanism
  • Some processes are intrinsically more important
    at some times than others
  • Time-dependent response
  • High-priority request
  • How can a process raise its scheduling priority?

34
Summary
  • Scheduler responsible for many goals
  • Scheduling algorithms complex
  • Know your math!
Write a Comment
User Comments (0)
About PowerShow.com