Homework 2: The Smokers Problem
This assignment is given on 09/02/1995. It is due on tuesday 21/02/95 in class, type-written, in Pseudo-English.
Solve (
Hints
) the Modified Cigarette Smokers Problem:
There are three SMOKER processes t, w, and m.
There are three AGENT processes T, W, and M.
Between them is a table.
SMOKER m has an infinite supply of matches.
SMOKER w has an infinite supply of wrapper.
SMOKER t has an infinite supply of tobacco.
AGENT M has an infinite supply of tobacco and wrapper.
AGENT W has an infinite supply of matches and tobacco.
AGENT T has an infinite supply of matches amd wrapper.
The smokers, in an infinite loop, think, get the missing ingredients from the table (getting both ingredients at the same time), and smoke.
The agents in an infinite loop put requested ingredients on the table as soon as they can.
While a smoker is picking ingredients no one can use the table.
While an agent is depositing an ingredient no one can use the table.
Implement your solution using:
parbegin ... parend
semaphores
global variables and variables local to each process.
Here is an interesting
"trick solution"
.
ingargiola@cis.temple.edu