cisc 7310x c05a: basic concepts about multiprogramming€¦ · •multi-processor scheduling...

27
CISC 7310X C05a: Basic Concepts about Multiprogramming Hui Chen Department of Computer & Information Science CUNY Brooklyn College 2/28/2019 1 CUNY | Brooklyn College

Upload: others

Post on 06-Aug-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

CISC 7310X

C05a: Basic Concepts about Multiprogramming

Hui Chen

Department of Computer & Information Science

CUNY Brooklyn College

2/28/2019 1CUNY | Brooklyn College

Page 2: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Acknowledgement

• This slides are a revision of the slides by the authors of the textbook

2/28/2019 CUNY | Brooklyn College 2

Page 3: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Outline

• Basic Concepts

• Scheduling Criteria

• Scheduling Algorithms

• Thread Scheduling

• Multi-Processor Scheduling

• Real-Time CPU Scheduling

• Operating Systems Examples

• Algorithm Evaluation

2/28/2019 CUNY | Brooklyn College 3

Page 4: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

CPU-I/O Burst Cycle

• CPU–I/O Burst Cycle

• Process execution consists of a cycle of CPU execution and I/O wait

• CPU burst followed by I/O burst

2/28/2019 CUNY | Brooklyn College 4

Page 5: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

2/28/2019 CUNY | Brooklyn College 5

Page 6: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Multiprogramming

2/28/2019 CUNY | Brooklyn College 6

• Process rapidly switching back and forth to share the CPU time

• In a single processor core system, only one program is active at once (pseudoparallelsim) [Figure 2-1(c) in Tanenbaum & Bos, 2014]

Page 7: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Benefit of Multiprogramming

• CPU utilization can be improved due to multiprogramming

• Intuition

• When one process is waiting for I/O, another can be scheduled to CPU

2/28/2019 CUNY | Brooklyn College 7

Page 8: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

How much do we benefit?

2/28/2019 CUNY | Brooklyn College 8

Page 9: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Simple Multiprogramming Model

• Assumptions

• n processes in the main memory;

• a process spends a fraction p of its waiting for I/O independent of the others

• Analysis

• CPU is idle when all processes are waiting for I/O

• The probability that all n processes waiting for I/O is pn

• CPU Utilization = 1 - pn

2/28/2019 CUNY | Brooklyn College 9

Page 10: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Result from the Simple Modeling Multiprogramming• CPU utilization

2/28/2019 CUNY | Brooklyn College 10

• CPU utilization [Figure 2-6 in Tanenbaum & Bos, 2014]

Page 11: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Questions

• Review the concepts of multiprogramming and process

• Benefit of multiprogramming

• Model and simulation of multiprogramming

• Examples of simulation and graphing

• What are the assumptions in the model?

2/28/2019 CUNY | Brooklyn College 11

Page 12: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

What are the assumptions in the model?• n processes in the main memory and treated

equally

• A process spends a fraction p of its waiting for I/O independent of the others

2/28/2019 CUNY | Brooklyn College 12

Page 13: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

CPU Bursts Differ

• CPU burst distribution is of main concern

2/28/2019 CUNY | Brooklyn College 13

Page 14: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Histogram of CPU-burst Times

• Large number of short bursts, small number of longer bursts

2/28/2019 CUNY | Brooklyn College 14

Page 15: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

CPU Scheduler: Intuition

• Select processes to run on CPU to take advantage of the understanding of the CPU bursts distribution

2/28/2019 CUNY | Brooklyn College 15

Page 16: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

CPU Scheduler

• The CPU scheduler selects from among the processes in ready queue, and allocates the a CPU core to one of them

2/28/2019 CUNY | Brooklyn College 16

Page 17: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

CPU Scheduler: When, From and To?

2/28/2019 CUNY | Brooklyn College 17

Page 18: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Review: Process States

2/28/2019 CUNY | Brooklyn College 18

Page 19: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Review: Representation of Process Scheduling

2/28/2019 CUNY | Brooklyn College 19

Page 20: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

CPU Scheduler: When, From and To?• CPU scheduling decisions may take place

when a process:

• Switches from running to waiting state

• Switches from running to ready state

• Switches from waiting to ready

• Terminates

2/28/2019 CUNY | Brooklyn College 20

Page 21: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

CPU Scheduler

• Queue may be ordered in various ways

• Scheduling under 1 and 4 is nonpreemptive

• All other scheduling is preemptive

• Consider access to shared data

• Consider preemption while in kernel mode

• Consider interrupts occurring during crucial OS activities

2/28/2019 CUNY | Brooklyn College 21

Page 22: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Preemptive and NonpreemptiveScheduling• Scheduling under the following is nonpreemptive

• Switches from running to waiting state

• Terminates

• All other scheduling is preemptive, such as,

• Switches from running to ready state

• Switches from waiting to ready

• For preemptive scheduling,

• Consider access to shared data

• Consider preemption while in kernel mode

• Consider interrupts occurring during crucial OS activities

2/28/2019 CUNY | Brooklyn College 22

Page 23: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Ready Queue

• Queue may be ordered in various ways

2/28/2019 CUNY | Brooklyn College 23

Page 24: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Questions?

• CPU scheduler

• Preemptive and nonpreemptive scheduling

2/28/2019 CUNY | Brooklyn College 24

Page 25: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Dispatcher

• Dispatcher module gives control of the CPU to the process selected by the short-term scheduler; this involves:

• switching context

• switching to user mode

• jumping to the proper location in the user program to restart that program

2/28/2019 CUNY | Brooklyn College 25

Page 26: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Dispatch Latency

• Time it takes for the dispatcher to stop one process and start another running

2/28/2019 CUNY | Brooklyn College 26

Page 27: CISC 7310X C05a: Basic Concepts about Multiprogramming€¦ · •Multi-Processor Scheduling •Real-Time CPU Scheduling •Operating Systems Examples •Algorithm Evaluation 2/28/2019

Questions?

• Dispatcher and dispatcher latency

2/28/2019 CUNY | Brooklyn College 27