240 likes | 399 Views
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D. Operating Systems {week 04}. 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
E N D
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D. Operating Systems{week 04}
Systems and models • A system is a part of the real worldthat we wish to analyze • Made up of autonomous entitiesinteracting with one another • A model is an abstractrepresentation of a system • We use models in analysis and design • Only relevant properties are included
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 ontime, input parameters, and eventsgenerated within the environment
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
Modeling uncertainty • Mathematical models can be categorized as: • Deterministic: • Behavior is predictable with 100% certainty • Stochastic: • Behavior is uncertain, based on random events
Stochastic models • A stochastic model is one thatincorporates uncertainty intoits behavior • One or more attributes change their values according to a probability distribution
Probability distributions (i) • A probability distribution specifies the probability of each value of somerandom variable • Uniform distribution: • All values areequally probable
Probability distributions (ii) • A probability distribution specifies the probability of each value of somerandom variable • Normal distribution: • Values are moreprobable at ornear the mean • This will forma bell curve
Probability distributions (iii) • A probability distribution specifies the probability of each valueof some random variable • Exponential distribution: • Values are times betweenevents in a Poisson processin which events occur bothcontinuously and independently,but at a constant average rate
Analyzing operating systems (i) • To study the performance of an operating system, we can: • Take measurements onthe real system • e.g. Unix time command • Run a simulation model • Apply an analytical model • e.g. Queuing theory, exponential distributions, etc.
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
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)
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)
Process scheduling and queues • Processes are created bythe operating system • Processes initially added toa job queue, which containsall processes waiting to enter the system • From the job queue, processes thatare ready for execution are addedto the ready queue
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
Long-term scheduling (i) • The long-term scheduler isinvoked infrequently
Long-term scheduling (ii) • The degree of multiprogramming ofan 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
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
Short-term (CPU) scheduling (ii) the dispatcher operates here
CPU-I/O burst cycle (i) • Processes alternate betweenCPU execution and I/O wait • A CPU burst is actual programexecution that uses the CPU • An I/O burst is a blocked state • Each process starts and endswith a CPU burst
CPU-I/O burst cycle (ii) • Histogram of CPU burst time frequencies
CPU scheduling algorithms (i) • CPU scheduling requires an algorithm todetermine which process to dispatch next • Scheduling algorithms include: • First-Come, First-Served (FCFS) • Shortest-Job-First (SJF) • Round-Robin (RR) • Priority • Multilevel Queue (MQ)
process CPU scheduling algorithms (ii) • Preemptive scheduling preempts a running process before itstime slice expires • Or it preempts a processbecause 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
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