OPERATING SYSTEMS DESIGN AND IMPLEMENTATION Third Edition ANDREW S. TANENBAUM ALBERT S. WOODHULL Yan hao (Wilson) Wu University of the Western.

Slides:



Advertisements
Similar presentations
1 Interprocess Communication 1. Ways of passing information 2. Guarded critical activities (e.g. updating shared data) 3. Proper sequencing in case of.
Advertisements

Operating Systems: Monitors 1 Monitors (C.A.R. Hoare) higher level construct than semaphores a package of grouped procedures, variables and data i.e. object.
1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Tanenbaum & Woodhull, Operating Systems: Design and Implementation, (c) 2006 Prentice-Hall, Inc. All rights reserved OPERATING SYSTEMS DESIGN.
Operating Systems Mehdi Naghavi Winter 1385.
CS 149: Operating Systems February 3 Class Meeting
Chapter 2 Processes and Threads
Chapter 6: Process Synchronization
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Operating Systems Operating Systems - Winter 2009 Chapter 2 - Processes Vrije Universiteit Amsterdam.
CY2003 Computer Systems Lecture 05 Semaphores - Theory.
6.5 Semaphore Can only be accessed via two indivisible (atomic) operations wait (S) { while S
1 Threads CSCE 351: Operating System Kernels Witawas Srisa-an Chapter 4-5.
Classical Problems of Concurrency
Chapter 2: Processes Topics –Processes –Threads –Process Scheduling –Inter Process Communication (IPC) Reference: Operating Systems Design and Implementation.
Avishai Wool lecture Introduction to Systems Programming Lecture 4 Inter-Process / Inter-Thread Communication.
Chapter 6: Process Synchronization. Outline Background Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores Classic Problems.
Concurrency: Deadlock and Starvation Chapter 6. Revision Describe three necessary conditions for deadlock Which condition is the result of the three necessary.
Chapter 2 Processes and Threads Scheduling Classical Problems.
Chapter 7 – Deadlock and Indefinite Postponement
1 Lecture 10: Uniprocessor Scheduling. 2 CPU Scheduling n The problem: scheduling the usage of a single processor among all the existing processes in.
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION Third Edition ANDREW S. TANENBAUM ALBERT S. WOODHULL Yan hao (Wilson) Wu University of the Western.
Operating Systems CSE 411 CPU Management Oct Lecture 13 Instructor: Bhuvan Urgaonkar.
1 Concurrency: Deadlock and Starvation Chapter 6.
1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Exam Review Operating Systems CS 550. Items of Interest Exam is Nov. 19, 2014 Focus on material since last exam, though knowledge of initial material.
Chapter 2 Processes and Threads Scheduling Classical Problems.
Processes (Διεργασίες)
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
Processes and Threads.
1 Process States (1) Possible process states –running –blocked –ready Transitions between states shown.
Chapter 6 CPU SCHEDULING.
Scheduling Chap 2. Scheduling Introduction to Scheduling (1) Bursts of CPU usage alternate with periods of I/O wait –a CPU-bound process –an I/O bound.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 23 Classic Synchronization.
1 Processes Chapter Processes 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 2 Processes and Threads Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
1 Scheduling The part of the OS that makes the choice of which process to run next is called the scheduler and the algorithm it uses is called the scheduling.
Chapter 1 Computer System Overview Sections 1.1 to 1.6 Instruction exe cution Interrupt Memory hierarchy Cache memory Locality: spatial and temporal Problem.
Operating Systems Scheduling. Bursts of CPU usage alternate with periods of waiting for I/O. (a) A CPU-bound process. (b) An I/O-bound process. Scheduling.
1 Interprocess Communication (IPC) - Outline Problem: Race condition Solution: Mutual exclusion –Disabling interrupts; –Lock variables; –Strict alternation.
OBJECTIVE: To learn about the various system calls. To perform the various CPU scheduling algorithms. To understand the concept of memory management schemes.
Operating Systems Inter-Process Communications. Lunch time in the Philosophy Department. Dining Philosophers Problem (1)
CSC 322 Operating Systems Concepts Lecture - 10: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Tasks and Task Management : --Time-critical tasks --Contending tasks --Communicating tasks.
CS 241 Section Week #7 (10/22/09). Topics This Section  Midterm Statistics  MP5 Forward  Classical Synchronization Problems  Problems.
Concurrency in Shared Memory Systems Synchronization and Mutual Exclusion.
6.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Module 6: Process Synchronization.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 3-3: Process Synchronization Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
CS4315A. Berrached:CMS:UHD1 Process Synchronization Chapter 8.
Dining Philosophers & Monitors Questions answered in this lecture: How to synchronize dining philosophers? What are monitors and condition variables? What.
1 Processes and Threads Part II Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
操作系统原理 OPERATING SYSTEM Chapter 2 Processes and Threads 进程与线程.
INTRO TO PROCESS SCHEDULING Module 2.4 COP4600 – Operating Systems Richard Newman.
Interprocess Communication Race Conditions
Chapter 5: Process Synchronization – Part 3
Auburn University COMP 3500 Introduction to Operating Systems Synchronization: Part 4 Classical Synchronization Problems.
Classical Synchronization Problems
Applied Operating System Concepts -
Chapter 2 Scheduling.
HW1 and Synchronization & Queuing
Definitions Concurrent program – Program that executes multiple instructions at the same time. Process – An executing program (the running JVM for Java.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Chapter 5: Process Synchronization (Con’t)
Message Passing, Scheduler
Processes and Threads Part III
Chapter 7: Synchronization Examples
Concurrency: Mutual Exclusion and Process Synchronization
Presentation transcript:

OPERATING SYSTEMS DESIGN AND IMPLEMENTATION Third Edition ANDREW S. TANENBAUM ALBERT S. WOODHULL Yan hao (Wilson) Wu University of the Western Cape Computer Science Department

The Producer-Consumer Problem Producer Consume r 1 N Buffer InOut Description: Producer and consumer share a buffer with N slots Producer: produce one data and put into a empty slot at one time. Block itself if no empty slot available l Consumer: consume one data a time. Block itself if no data available Out = Out % NIn = In % N

The Producer-Consumer Problem (1) Figure The producer-consumer problem with a fatal race condition.

The Producer-Consumer Problem (2) Figure The producer-consumer problem with a fatal race condition

The Producer-Consumer Problem Mutual exclusion Mutex: only one process or thread can operate a slot at a time Synchronization empty: indicate how many slots is empty now full: indicate how many slots is full now relationship: when “empty = empty -1”, “full = full +1” (P V)

Monitors (1) Figure A monitor.

Monitors (2) Figure An outline of the producer-consumer problem with monitors. Only one monitor procedure at a time is active. The buffer has N slots

The Producer-Consumer Problem (3) Figure The producer-consumer problem using semaphores. Note:when buffer is full, producer will block at the second down with mutex =0 -> Deadlock: Producer block by empty semaphore, Consumer block by mutex semaphore

The Producer-Consumer Problem (4) Figure The producer-consumer problem using semaphores.

Message Passing (1) Figure The producer-consumer problem with N messages.

Message Passing (2)

The Dining Philosophers Problem (1) Figure Lunch time in the Philosophy Department. There are 5 philosophers sitting at a round table. Between each adjacent pair of philosophers is a chopstick. In other words, there are five chopsticks. Each philosopher does two things: think and eat. The philosopher thinks for a while, and then stops thinking and becomes hungry. When the philosopher becomes hungry, he/she cannot eat until he/she owns the chopsticks to his/her left and right. When the philosopher is done eating he/she puts down the chopsticks and begins thinking again.

The Dining Philosophers Problem (2) Figure A nonsolution to the dining philosophers problem. Deadlock->Starvation: All the programs continue to run indefinitely but fail to make any progress is called starvation

The Dining Philosophers Problem (3)

The Dining Philosophers Problem (4)

The Dining Philosophers Problem (5) Figure A solution to the dining philosophers problem.

The Readers and Writers Problem (1)

The Readers and Writers Problem (2)

Process Behavior (1) Figure Bursts of CPU usage alternate with periods of waiting for I/O. (a) A CPU-bound process. (b) An I/O-bound process.

When to Schedule When scheduling is absolutely required: 1. When a process exits. 2. When a process blocks on I/O, or a semaphore. When scheduling usually done (though not absolutely required) 1. When a new process is created. 2. When an I/O interrupt occurs. 3. When a clock interrupt occurs.

Scheduling Algorithms (1)

Scheduling Algorithms (2) Figure An example of shortest job first scheduling. (a) Running four jobs in the original order. (b) Running them in shortest job first order.

Shortest Job First P1 P2 P3 P4 Turnaround time: P1 P2 P3 P4 average time:

Three Level Scheduling (1) Figure Three-level scheduling.

Three Level Scheduling (2) Criteria for deciding which process to choose(memory scheduler): How long has it been since the process was swapped in or out? How much CPU time has the process had recently? How big is the process? How important is the process?

Round-Robin Scheduling Figure Round-robin scheduling. (a) The list of runnable processes. (b) The list of runnable processes after B uses up its quantum.

Priority Scheduling Figure A scheduling algorithm with four priority classes.

Real time scheduling A:20ms 10ms B:50ms 25ms ABAB m ∑ i=1 CiCi PiPi <=1 Schedulable

Thread Scheduling (1) Figure (a) Possible scheduling of user-level threads with a 50- msec process quantum and threads that run 5 msec per CPU burst.

Thread Scheduling (2) Figure (b) Possible scheduling of kernel-level threads with the same characteristics as (a).