Parallel Programming WS 2014/2015 - Solution 4
Kastens, PfahlerInstitut für Informatik, Fakultät für Elektrotechnik, Informatik und Mathematik, Universität Paderborn
Dec 08, 2014
Solution for Exercise 1
- a)
- The monitor invariant:
// to be enforced by waiting seats >= seated >= transported // guaranteed by execution order seats >= transported
- b)
- The necessary waiting conditions and counter increments:
Entry Procedure wait while ... Modify counters ride seats <= seated
seated++;
offer seats += 8;
seated < transported + 8;
transported += 8;
- c)
-
To substitute the increasing counters by limited counters, we define
two new counters:
freeseats = seats - seated entered = seated - transported
The counter actions and waiting conditions are transformed to:Entry Procedure wait while ... Modify counters ride freeseats <= 0
freeseats--; entered++;
offer freeseats = 8;
entered < 8;
entered = 0;
- d)
- LAB:
A Java monitor that can be used with the FAShuttle simulation is provided in
directory
blatt4/FAShuttle.sol
.
Solution for Exercise 2
Directory blatt4/dices.sol
contains an implementation
of the complete dice simulation.
Generiert mit Camelot | Probleme mit Camelot? | Geändert am: 09.01.2015