Barbershop Example We can simulate a barbershop using semaphores.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Barber Shop 1 Barber Customer Queue. 2 C1C2C3 Barber Before Opening Customers waiting in queue.
Unit 4, Lesson 7 Created by: Nancy Luebbers Hamilton ECEC
矩陣乘法 實作矩陣乘法 利用 threads 來加速運算速度 – Matrix1 row x Matrix2 column = Ans (x,y) Matrix 1Matrix 2Answer.
1 CS 333 Introduction to Operating Systems Class 5 – Classical IPC Problems Jonathan Walpole Computer Science Portland State University.
Semaphores. Announcements No CS 415 Section this Friday Tom Roeder will hold office hours Homework 2 is due today.
1 Sleeping Barber Problem There is one barber, and n chairs for waiting customers If there are no customers, then the barber sits in his chair and sleeps.
Solutions Queueing Theory 1
ALLAH DOES EXIST …. This is one of the best explanations of why Allah allows pain and suffering :
CY2003 Computer Systems Lecture 11 Review Lecture.
18/02/08Week 21 CENG334 Introduction to Operating Systems Erol Sahin Dept of Computer Eng. Middle East Technical University Ankara, TURKEY URL:
More Synchronisation Last time: bounded buffer, readers-writers, dining philosophers Today: sleeping barber, monitors.
The Cutting Edge. Company Description The Cutting Edge is the new barbershop in town that incorporates both old school methods of cutting hair with new.
5.4 Which of the following scheduling algorithms could result in starvation? a. First-come, first-served b. Shortest job first c. Round robin d. Priority.
By Margaree King Mitchell Illustrated by James Ransome.
W E L C O M E Nevitt Computer Lab Mrs. West. E X P E C T A T I O N S Be R espectful Be R esponsible Be R eady to learn.
Operating Systems Review for Chap.6 & 7 Hung Q. Ngo KyungHee University Spring 2009
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Classical problems.
Thread Synchronization Tutorial #8 CPSC 261. A thread is a virtual processor Each thread is provided the illusion that it owns a core – Copy of the registers.
Homework Assignment #2 J. H. Wang Oct. 17, 2007.
Semaphores Ref: William Stallings G.Anuradha. Principle of a Semaphore Two or more processes can cooperate by means of simple signals, such that a process.
CSE 451 Section Thursday, October 30. Questions from Lecture?
CPS110: Threads review and wrap up Landon Cox February 11, 2009.
6.EE.C.Represent and analyze quantitative relationships between dependent and independent variables. 9.Use variables to represent two quantities in a real-world.
Process Synchronization CS 360. Slide 2 CS 360, WSU Vancouver Process Synchronization Background The Critical-Section Problem Synchronization Hardware.
CS 3340 Windows Programming. Course Evaluation Course Outcomes Not about the instructor Do it Today! 2.
课标人教实验版 高一 Module 3 Unit 3. Writing It sounds difficult to write a play, even a small part of it sounds difficult. Writing a play or drama is quite different.
Synchronization, part 3 Monitors, classical sync. problems
Generic Seating Chart Directions:
SquirE Barber Appointment app
Announcement server: server.o common.o $(CC) -o server server.o common.o $(LIBS) -lsock -lpthread and change it to: server: server.o common.o threadpool.o.
Dining Philosophers Five philosophers sit around a table
CPS110: Threads review and wrap up
Synchronization, part 3 Monitors, classical sync. problems
CS 3340 Windows Programming
UNIVERSITY EXAM: EXAMINATION RULES FOR STUDENTS
2.4 Classic IPC Problems Dining philosophers Readers and writers
Monitors, Condition Variables, and Readers-Writers
Hair SensationsHair Sensations, your hair is your crowning glory. It says a lot about your personality, your style and your interests. Our goal is help.

Ref: William Stallings,Galvin, Naresh Chauhan G.Anuradha
BACK SOLUTION:
Synchronization, part 3 Monitors, classical sync. problems
We’re Going on a Trip.
Solutions Queueing Theory 1
Instructor Provided Questions
Principles of Software Development
Jill got to the grocery store at 11:20
GENERAL EXAM: EXAMINATION RULES FOR STUDents
Going to the dentist Created by Paul Selke, MN educator at SHAPE.
Lesson Aims Vocabulary In this lesson you are going to:
Generic Seating Chart Directions:
Synchronization, part 3 Monitors, classical sync. problems
Start Finish Find the solution 42 out of out of 2200
Solutions Queueing Theory 1
Synchronization, part 3 Monitors, classical sync. problems
Critical section problem
UNIVERSITY EXAM: EXAMINATION RULES FOR STUDents
UNIVERSITY EXAM: EXAMINATION RULES FOR STUDENTS
Solutions Queueing Theory 1
February 5, 2004 Adrienne Noble
Around the room Orders of operations.
CHAMPS: Independent Work
CHAMPS: Independent Work
No Warm-Up: 8/21/17 Students Are… Sitting in their assigned seats.
CHAMPS: Mrs. Worthy is Teaching
Wigston College June PPEs 2019.
Synchronization, part 3 Monitors, classical sync. problems
Congrats Class of One Eight!
 When entering the competition room, please look for your place: your name and competitor ID are indicated. Registration and control of the participation.
Presentation transcript:

Barbershop Example We can simulate a barbershop using semaphores. The barbershop has three chairs, three barbers, a waiting room for up to 20 customers, and 4 of these waiting customers may sit on the couch. Note that the Barbershop example is in Appendix A of the textbook.

Problem There is a problem with this barbershop. In a real barbershop, if three customers in a row are seated for a haircut, the haircuts will not necessarily be completed in that order (one customer may not have much hair to cut). However, our code will cause the first customer seated to leave and pay as soon as any haircut is finished. A solution uses a separate semaphore for each customer.