CMPS-3600 Operating Systems
Lab-9
Use of mutex for mutual exclusion

Start
Do your work in your Odin 3600/9 folder.

Get the starting program like this...

  $ cd 3600/9
  $ cp /home/fac/gordon/public_html/3600a/examples/9/crash2.c tvlab9.c

We will build a Makefile together.

Running the program will look like this:



  • The yellow rectangle is the intersection of two roads.
  • The colored boxes are cars driving on the road.
  • The red and green cars are having a collision.
  • Don't let collisions occur.

This program contains several new features.

   1. Double buffering of graphics.
      This eliminates shearing or flickering of graphics animation.

   2. Close window with click on X in title bar.



Assignment...

1. Figure out where the critical section of code is.

2. Protect the critical section with a mutex.

   You may use the same mutex we used in the dining philosophers program.

3. Add some text in the window showing the number of times each
   car passes through the intersection.
   This allows us to check for starvation.


Other things you may add...

4. Add one new car.
   There is room in each lane for another car.
   Choose North, South, East, or West bound.

5. Add one new car to each lane.



Additional...



Files to be collected...
  tvlab9.c
  Makefile