Lecture 18 Syed Mansoor Sarwar

Slides:



Advertisements
Similar presentations
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
Advertisements

Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 19 Scheduling IV.
1 Friday, June 16, 2006 "In order to maintain secrecy, this posting will self-destruct in five seconds. Memorize it, then eat your computer." - Anonymous.
Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Silberschatz, Galvin and Gagne ©2007 Processes and Their Scheduling.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization.
Cs238 CPU Scheduling Dr. Alan R. Davis. CPU Scheduling The objective of multiprogramming is to have some process running at all times, to maximize CPU.
Chapter 6: Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Module 6: Synchronization 6.1 Background 6.2 The Critical-Section.
A. Frank - P. Weisberg Operating Systems Introduction to Cooperating Processes.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
General What is an OS? What do you get when you buy an OS? What does the OS do? What are the parts of an OS? What is the kernel? What is a device.
Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server Systems.
Chapter 6 Scheduling. Basic concepts Goal is maximum utilization –what does this mean? –cpu pegged at 100% ?? Most programs are I/O bound Thus some other.
Concurrency, Mutual Exclusion and Synchronization.
ICS Principles of Operating Systems Lecture 5 - CPU Scheduling Prof. Nalini Venkatasubramanian
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure the orderly execution.
Processes. Process Concept Process Scheduling Operations on Processes Interprocess Communication Communication in Client-Server Systems.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Operating Systems CPU Scheduling Algorithms
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Process Synchronization. Objectives To introduce the critical-section problem, whose solutions can be used to ensure the consistency of shared data To.
CE Operating Systems Lecture 8 Process Scheduling continued and an introduction to process synchronisation.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
CPU SCHEDULING.
Dan C. Marinescu Office: HEC 439 B. Office hours: M, Wd 3 – 4:30 PM.
Topic 3 (Textbook - Chapter 3) Processes
Background on the need for Synchronization
Chapter 5a: CPU Scheduling
Chapter 3: Process Concept
Chapter 5: Process Synchronization
CPU scheduling 6. Schedulers, CPU Scheduling 6.1. Schedulers
CPU Scheduling.
Chapter 6: CPU Scheduling
Chapter 6: CPU Scheduling
ICS 143 Principles of Operating Systems
Chapter 4: Processes Process Concept Process Scheduling
CS 143A - Principles of Operating Systems
CPU Scheduling G.Anuradha
Lecture 16 Syed Mansoor Sarwar
Module 5: CPU Scheduling
Operating Systems Lecture 15.
Operating System Concepts
Topic 6 (Textbook - Chapter 5) Process Synchronization
Lecture 17 Syed Mansoor Sarwar
3: CPU Scheduling Basic Concepts Scheduling Criteria
Process Synchronization
Lecture 19 Syed Mansoor Sarwar
Introduction to Cooperating Processes
Chapter5: CPU Scheduling
COT 4600 Operating Systems Spring 2011
Chapter 6: CPU Scheduling
CPU SCHEDULING.
Operating System Concepts
COT 4600 Operating Systems Fall 2009
Grades.
Chapter 6: Process Synchronization
Lecture 2 Part 3 CPU Scheduling
Operating System , Fall 2000 EA101 W 9:00-10:00 F 9:00-11:00
Chapter 6: Synchronization Tools
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
Outline Chapter 2 (cont) Chapter 3: Processes Virtual machines
Chapter 6: Scheduling Algorithms Dr. Amjad Ali
Chapter 3: Process Concept
Chapter 6: CPU Scheduling
Module 5: CPU Scheduling
CHAPTER 6 CPU SCHEDULING
Presentation transcript:

Lecture 18 Syed Mansoor Sarwar Operating Systems Lecture 18 Syed Mansoor Sarwar

© Copyright Virtual University of Pakistan Agenda for Today Review of previous lecture UNIX System V scheduling Algorithm evaluation Process synchronization Recap of lecture 27 February 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Review of Lecture 17 Multi-level queues scheduling Multi-level feedback queues scheduling UNIX System V scheduling algorithm 27 February 2019 © Copyright Virtual University of Pakistan

UNIX System V Scheduling Algorithm Every second, the priority number of all those processes that are in the main memory and ready to run is updated by using the following formula: Priority# = (Recent CPU Usage)/2 + Thr. Pri.+ nice Threshold priority and nice values are always positive to prevent a user from migrating out of its assigned group 27 February 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan UNIX System V Example PA PB PC CPU Count 1 … 60 30 15 7 8 67 33 16 CPU Count 1 … 60 30 15 7 8 67 33 CPU Count 1 … 60 30 15 7 Time Priority 60 75 67 63 76 68 Priority 60 75 67 63 76 Priority 60 75 67 63 1 2 3 4 5 27 February 2019 © Copyright Virtual University of Pakistan

Round Robin Scheduling and Process Priorities 60 B Higher Priority B A A A 1 2 3 B A B B A runs first A 27 February 2019 © Copyright Virtual University of Pakistan 4 5 6

© Copyright Virtual University of Pakistan Algorithm Evaluation Analytic Evaluation The algorithm and some system workload are used to produce a formula or number which gives the performance of the algorithm for that workload. Deterministic modeling Queuing models Implementation 27 February 2019 © Copyright Virtual University of Pakistan

Deterministic Modeling Predetermined workload and performance of each algorithm for that workload. Use of Gantt charts. Simple and fast Exact numbers for comparison Requires exact input Performance figures may not be true in general 27 February 2019 © Copyright Virtual University of Pakistan

Deterministic Modeling Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 Gantt chart Average waiting time = (9 + 1 + 0 +2)/4 = 3 P3 P2 4 2 11 P4 5 7 P1 16 27 February 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Queuing Modeling Computer system viewed as a network of queues and servers: ready queue, I/O queue, event queues, CPUs, I/O device controllers, etc. Input: Arrival and service rates Output: CPU utilization, average queue length, average waiting time, … 27 February 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Queuing Modeling Little’s Formula: n = λ* W where n = average queue length λ = average arrival rate W = average waiting time in a queue 27 February 2019 © Copyright Virtual University of Pakistan

Queuing Modeling Let the average job arrival rate be 0.5 Algorithm Average Wait Time W=tw Average Queue Length(n) FCFS 4.6 2.3 SJF 3.6 1.8 SRTF 3.2 1.6 RR (q=1) 7.0 3.5 RR (q=4) 6.0 3.0 27 February 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Queuing Modeling Complicated mathematics Distributions (Poisson, uniform, exponential, etc) for the arrival and departure rates can be difficult to work with Assumptions may not be accurate Approximation of the real system 27 February 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Simulation Programming model for the computer system Workload generated by assuming some distribution and a random number generator, or by collecting data from the actual system. 27 February 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Simulation Characteristics Expensive: hours of programming and execution time May be erroneous because of the assumptions about distributions 27 February 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Simulation 27 February 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Implementation Best Most expensive Good option due to Open Source kernels such as Linux 27 February 2019 © Copyright Virtual University of Pakistan

Process Synchronization Concurrent access to shared data may result in data inconsistency. Maintaining data consistency requires mechanisms to ensure that cooperating processes access shared data sequentially. 27 February 2019 © Copyright Virtual University of Pakistan

Bounded-Buffer Problem Shared data #define BUFFER_SIZE 10 typedef struct { . . . } item; item buffer[BUFFER_SIZE]; int in = 0, out = 0; int counter = 0; 27 February 2019 © Copyright Virtual University of Pakistan

Bounded-Buffer Problem Producer process item nextProduced; … while (1) { while (counter == BUFFER_SIZE) ; buffer[in] = nextProduced; in = (in + 1) % BUFFER_SIZE; counter++; } 27 February 2019 © Copyright Virtual University of Pakistan

Bounded-Buffer Problem Consumer process item nextConsumed; while (1) { while (counter == 0) ; nextConsumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; counter--; } 27 February 2019 © Copyright Virtual University of Pakistan

Bounded-Buffer Problem “counter++” in assembly language MOV R1, counter INC R1 MOV counter, R1 “counter--” in assembly language MOV R2, counter DEC R2 MOV counter, R2 27 February 2019 © Copyright Virtual University of Pakistan

Bounded-Buffer Problem If both the producer and consumer attempt to update the buffer concurrently, the machine language statements may get interleaved. Interleaving depends upon how the producer and consumer processes are scheduled. 27 February 2019 © Copyright Virtual University of Pakistan

Bounded-Buffer Problem Assume counter is initially 5. One interleaving of statements is: producer: MOV R1, counter (R1 = 5) INC R1 (R1 = 6) consumer: MOV R2, counter (R2 = 5) DEC R2 (R2 = 4) producer: MOV counter, R1 (counter = 6) consumer: MOV counter, R2 (counter = 4) The value of count may be either 4 or 6, where the correct result should be 5. 27 February 2019 © Copyright Virtual University of Pakistan

Process Synchronization Race Condition: The situation where several processes access and manipulate shared data concurrently, the final value of the data depends on which process finishes last. 27 February 2019 © Copyright Virtual University of Pakistan

Process Synchronization Critical Section: A piece of code in a cooperating process in which the process may updates shared data (variable, file, database, etc.). Critical Section Problem: Serialize executions of critical sections in cooperating processes 27 February 2019 © Copyright Virtual University of Pakistan

Solution of the Critical Problem Software based solutions Hardware based solutions Operating system based solution 27 February 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Structure of Solution do { critical section reminder section } while (1); entry section exit section 27 February 2019 © Copyright Virtual University of Pakistan

© Copyright Virtual University of Pakistan Recap of Lecture UNIX System V scheduling Algorithm evaluation Process synchronization Recap of lecture 27 February 2019 © Copyright Virtual University of Pakistan

Lecture 18 Syed Mansoor Sarwar Operating Systems Lecture 18 Syed Mansoor Sarwar