Operating Systems { week 04b}

24
Operating Systems {week 04b} Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.

description

Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D. Operating Systems { week 04b}. Systems and models. A system is a part of the real world that we wish to analyze Made up of autonomous entities interacting with one another - PowerPoint PPT Presentation

Transcript of Operating Systems { week 04b}

Page 1: Operating Systems { week  04b}

Operating Systems{week 04b}

Rensselaer Polytechnic InstituteCSCI-4210 – Operating SystemsDavid Goldschmidt, Ph.D.

Page 2: Operating Systems { week  04b}

Systems and models

A system is a part of the real worldthat we wish to analyze Made up of autonomous entities

interacting with one another

A model is an abstractrepresentation of a system We use models in analysis and design Only relevant properties are included

Page 3: Operating Systems { week  04b}

Using models for analysis (i) Simulate a system’s behavior using a

model Models have tunable input parameters Observe the simulation; analyze output

Predict behavior of the real systemby analyzing behavior of the model Behavior of the model depends on

time, input parameters, and eventsgenerated within the environment

Page 4: Operating Systems { week  04b}

Using models for analysis (ii) We can model numerous systems

usingthe following components: User: a single user of the system

Service: a node providing a service

Queue: an array of users waiting for service

Page 5: Operating Systems { week  04b}

Modeling uncertainty

Mathematical models can be categorized as: Deterministic:▪ Behavior is predictable with 100% certainty

Stochastic:▪ Behavior is uncertain, based on random

events

Page 6: Operating Systems { week  04b}

Stochastic models

A stochastic model is one thatincorporates uncertainty intoits behavior One or more attributes change their

values according to a probability distribution

Page 7: Operating Systems { week  04b}

Probability distributions (i) A probability distribution specifies the

probability of each value of somerandom variable Uniform distribution: All values are

equally probable

Page 8: Operating Systems { week  04b}

Probability distributions (ii) A probability distribution specifies the

probability of each value of somerandom variable Normal distribution: Values are more

probable at ornear the mean

This will forma bell curve

Page 9: Operating Systems { week  04b}

Probability distributions (iii) A probability distribution specifies the

probability of each valueof some random variable Exponential distribution: Values are times between

events in a Poisson processin which events occur bothcontinuously and independently,but at a constant average rate

Page 10: Operating Systems { week  04b}

Analyzing operating systems (i) To study the performance of an

operating system, we can: Take measurements on

the real system▪ e.g. Unix time command

Run a simulation model Apply an analytical model▪ e.g. Queuing theory, exponential

distributions, etc.

Page 11: Operating Systems { week  04b}

Analyzing operating systems (ii) External performance goals:

Minimize user response time Maximize throughput▪ Number of jobs completed per unit time

Minimize turnaround time▪ Average time to complete jobs

Maximize fairness Maximize degree of multiprogramming▪ Number of processes supported without

degradation

Page 12: Operating Systems { week  04b}

Analyzing operating systems (iii) Internal performance goals:

Maximize CPU utilization Maximize disk utilization Minimize disk access time Enforce priorities Minimize overhead▪ e.g. time for scheduling algorithm, context

switching Avoid starvation of long-running jobs Enforce real-time deadlines (sometimes)

Page 13: Operating Systems { week  04b}

Analyzing operating systems (iv) Some key performance measures:

Average number of jobs in the system Average number of jobs waiting in a

queue Average time a job spends in the system Average time a job spends in the queues CPU utilization Total number of jobs serviced (i.e.

throughput)

Page 14: Operating Systems { week  04b}

Process scheduling and queues Processes are created by

the operating system Processes initially added to

a job queue, which containsall processes waiting to enter the system

From the job queue, processes thatare ready for execution are addedto the ready queue

Page 15: Operating Systems { week  04b}

Schedulers

A long-term scheduler (i.e. job scheduler) selects processes from the job queue, adding those processes to the ready queue

A short-term scheduler (i.e. CPU scheduler) selects processes from the ready queueand allocates time with the CPU

Page 16: Operating Systems { week  04b}

Long-term scheduling (i)

The long-term scheduler isinvoked infrequently

Page 17: Operating Systems { week  04b}

Long-term scheduling (ii) The degree of multiprogramming of

an operating system is defined asthe number of processes in memory In a stable operating system,

the average process arrival rate equalsthe average process departure rate

Page 18: Operating Systems { week  04b}

Short-term (CPU) scheduling (i) The short-term scheduler decides which

process the CPU executes next The dispatcher gives control of the CPU

to the process selected by the CPU scheduler: Performs context switch Switches to user mode Jumps to the proper location in the user

program to resume program execution

Page 19: Operating Systems { week  04b}

Short-term (CPU) scheduling (ii)

the dispatcher operates here

Page 20: Operating Systems { week  04b}

CPU-I/O burst cycle (i)

Processes alternate betweenCPU execution and I/O wait A CPU burst is actual program

execution that uses the CPU An I/O burst is a blocked state Each process starts and ends

with a CPU burst

Page 21: Operating Systems { week  04b}

CPU-I/O burst cycle (ii)

Histogram of CPU burst time frequencies

Page 22: Operating Systems { week  04b}

CPU scheduling algorithms (i) CPU scheduling requires an algorithm to

determine which process to dispatch next

Scheduling algorithms include: First-Come, First-Served (FCFS) Shortest-Job-First (SJF) Round-Robin (RR) Priority Multilevel Queue (MQ)

Page 23: Operating Systems { week  04b}

CPU scheduling algorithms (ii) Preemptive scheduling preempts a

running process before itstime slice expires Or it preempts a process

because its time slice has expired

Non-preemptive scheduling gives a process exclusive uninterrupted access to the CPU for the entirety of its execution

process

process process process

Page 24: Operating Systems { week  04b}

CPU scheduling algorithms (iii) Compare scheduling algorithms by

measuring CPU utilization – keep CPU as busy as possible Throughput – maximize the number of

processes that complete their execution per unit time

Turnaround time – minimize the elapsed time to fully execute a particular process

Waiting time – minimize the elapsed time a process waits in the ready queue