Synchronization driver problem changes.

This commit is contained in:
Geoffrey Challen
2015-12-31 14:53:16 -05:00
parent 2e721daedf
commit 3b2267123d
2 changed files with 40 additions and 66 deletions

View File

@@ -28,30 +28,33 @@
*/
/*
* Driver code is in kern/tests/synchprobs.c We will
* replace that file. This file is yours to modify as you see fit.
* Driver code is in kern/tests/synchprobs.c We will replace that file. This
* file is yours to modify as you see fit.
*
* You should implement your solution to the stoplight problem below. The
* quadrant and direction mappings for reference: (although the problem is,
* of course, stable under rotation)
* quadrant and direction mappings for reference: (although the problem is, of
* course, stable under rotation)
*
* | 0 |
* -- --
* 0 1
* 3 1
* 3 2
* -- --
* | 2 |
* -- -- 0 1 3 1 3 2
* -- -- | 2 |
*
* As way to think about it, assuming cars drive on the right: a car entering
* the intersection from direction X will enter intersection quadrant X
* first.
* the intersection from direction X will enter intersection quadrant X first.
* The semantics of the problem are that once a car enters any quadrant it has
* to be somewhere in the intersection until it call leaveIntersection(),
* which it should call while in the final quadrant.
*
* You will probably want to write some helper functions to assist
* with the mappings. Modular arithmetic can help, e.g. a car passing
* straight through the intersection entering from direction X will leave to
* direction (X + 2) % 4 and pass through quadrants X and (X + 3) % 4.
* Boo-yah.
* As an example, let's say a car approaches the intersection and needs to
* pass through quadrants 0, 3 and 2. Once you call inQuadrant(0), the car is
* considered in quadrant 0 until you call inQuadrant(3). After you call
* inQuadrant(2), the car is considered in quadrant 2 until you call
* leaveIntersection().
*
* You will probably want to write some helper functions to assist with the
* mappings. Modular arithmetic can help, e.g. a car passing straight through
* the intersection entering from direction X will leave to direction (X + 2)
* % 4 and pass through quadrants X and (X + 3) % 4. Boo-yah.
*
* Your solutions below should call the inQuadrant() and leaveIntersection()
* functions in synchprobs.c to record their progress.