<< Chapter < Page | Chapter >> Page > |
The original barbershop problem was proposed by Dijkstra. A variation of it appears in Silberschatz and Galvin’s OperatingSystems Concepts. A barbershop consists of a waiting room with n chairs, and the barber room containing the barber chair. If there are no customers to be served,the barber goes to sleep. If a customer enters the barbershop and all chairs are occupied, then the customer leaves the shop. If the barber is busy, but chairsare available, then the customer sits in one of the free chairs. If the barber is asleep, the customer wakes up the barber. Write a program to coordinate thebarber and the customers.
Until now we have talked about processes, from now on we will talk about resources, the things operated upon by processes. Resourcesrange from cpu time to disk space to channel I/O time.
Resources fall into two classes:
OS makes two related kinds of decisions about resources:
Processes may be in any one of three general scheduling states:
There are two parts to CPU scheduling:
This is an example of policy/mechanism separation.
Goals for Scheduling Disciplines
Run until finished.
Solution: limit maximum amount of time that a process can run without a context switch. This time is called a time slice.
Run process for one time slice, then move to back of queue. Each process gets equal share of the CPU. Most systems use somevariant of this. What happens if the time slice is not chosen carefully?
Notification Switch
Would you like to follow the 'Operating systems' conversation and receive update notifications?