G53OPS - Operating Systems

This course is run at the The University of Nottingham within the School of Computer Science & IT. The course is run by Graham Kendall (EMAIL : gxk@cs.nott.ac.uk)


Inter-Process Communication Problems

In this section we describe a few classic inter process communication problems. If you have the time and the inclination you might like to try and write a program which solves these problems.

The Producer-Consumer Problem

Assume there is a producer (which produces goods) and a consumer (which consumes goods). The producer, produces goods and places them in a fixed size buffer. The consumer takes the goods from the buffer.

The buffer has a finite capacity so that if it is full, the producer must stop producing.

Similarly, if the buffer is empty, the consumer must stop consuming.

This problem is also referred to as the bounded buffer problem.

The type of situations we must cater for are when the buffer is full, so the producer cannot place new items into it. Another potential problem is when the buffer is empty, so the consumer cannot take from the buffer.

The Dining Philosophers Problem

This problem was posed by (Dijkstra, 1965).

Five philosophers are sat around a circular table. In front of each of them is a bowl of food. In between each bowl there is a fork. That is there are five forks in all.

Philosophers spend their time either eating or thinking. When they are thinking they are not using a fork.

When they want to eat they need to use two forks. They must pick up one of the forks to their right or left. Once they have acquired one fork they must acquire the other one. They may acquire the forks in any order.

Once a philosopher has two forks they can eat. When finished eating they return both forks to the table.

The question is, can a program be written, for each philosopher, that never gets stuck, that is, a philosopher is waiting for a fork forever.

The Readers Writers Problem

This problem was devised by (Courtois et al., 1971). It models a number of processes requiring access to a database. Any number of processes may read the database but only one can write to the database.

The problem is to write a program that ensures this happens.

The Sleeping Barber Problem

A barber shop consists of a waiting room with n chairs. There is another room that contains the barbers chair. The following situations can happen.

· If there are no customers the barber goes to sleep.
· If a customer enters and the barber is asleep (indicating there are no other customers waiting) he wakes the barber and has a haircut.
· If a customer enters and the barber is busy and there are spare chairs in the waiting room, the customer sits in one of the chairs.
· If a customer enters and all the chairs in the waiting room are occupied, the customer leaves.

The problem is to program the barber and the customers without getting into race conditions.

Last Page Back to Main Index Next Page

 

 


 Last Updated : 13/01/2002