Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

3 Problems on Gillbirt Process of Magazine - Homework 3 | CS 4414, Assignments of Operating Systems

Material Type: Assignment; Class: Operating Systems; Subject: Computer Science; University: University of Virginia; Term: Unknown 2005;

Typology: Assignments

Pre 2010

Uploaded on 07/29/2009

koofers-user-82s
koofers-user-82s 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS414 Homework #3
Due Sept 27, 2005
1. Consider two processes: Gilbert and Shoe, and three reusable resources: a bathroom (which is
large enough for only 1 person), a single copy of magazine X, and a single copy of magazine Y.
The Gilbert process behaves as follows:
get magazine Y
get magazine X
release Y
get bathroom
release X
release bathroom
The Shoe process behaves as follows:
get magazine X
get magazine Y
release X
release Y
get bathroom
release bathroom
Each process is asynchronous and repeats its behavior cycle indefinitely.
(1) Using semaphores, implement appropriate synchronization for these processes in a mul-
tiprogramming environment. Try to achieve the highest utilization of each resources.
You are not allowed to change the order in which any operations are performed (they are
very stubborn). The resulting system must be deadlock free.
(2) Show that your solution implements mutual exclusion with respect to the magazine X.
(3) Outline an informal argument that deadlock is not possible in your solution.
2. A barbershop consists of 5 waiting chairs and 1 barber chair. If there are no customers to be
served, the barber keep waiting for the customer. If a customer enters the barbershop and all
chairs are occupied (which happens almost always on Saturdays), then the customer leaves the
shop in disgust. If the barber is busy, then the customer sits in one of the available free chairs
and wait until the barber is free. Write a program to coordinate the barber and the customers
using semaphores. Explain all the assumptions and give an example to show that your solution
works correctly.
No hand-written homework! Pledge your homework.

Partial preview of the text

Download 3 Problems on Gillbirt Process of Magazine - Homework 3 | CS 4414 and more Assignments Operating Systems in PDF only on Docsity!

CS414 Homework

Due Sept 27, 2005

  1. Consider two processes: Gilbert and Shoe, and three reusable resources: a bathroom (which is large enough for only 1 person), a single copy of magazine X, and a single copy of magazine Y.

The Gilbert process behaves as follows:

get magazine Y get magazine X release Y get bathroom release X release bathroom

The Shoe process behaves as follows:

get magazine X get magazine Y release X release Y get bathroom release bathroom

Each process is asynchronous and repeats its behavior cycle indefinitely.

(1) Using semaphores, implement appropriate synchronization for these processes in a mul- tiprogramming environment. Try to achieve the highest utilization of each resources. You are not allowed to change the order in which any operations are performed (they are very stubborn). The resulting system must be deadlock free.

(2) Show that your solution implements mutual exclusion with respect to the magazine X.

(3) Outline an informal argument that deadlock is not possible in your solution.

  1. A barbershop consists of 5 waiting chairs and 1 barber chair. If there are no customers to be served, the barber keep waiting for the customer. If a customer enters the barbershop and all chairs are occupied (which happens almost always on Saturdays), then the customer leaves the shop in disgust. If the barber is busy, then the customer sits in one of the available free chairs and wait until the barber is free. Write a program to coordinate the barber and the customers using semaphores. Explain all the assumptions and give an example to show that your solution works correctly.

No hand-written homework! Pledge your homework.