
CS 3750 Class --

For the first phase of the programming assignment, create a
program that conforms to the guidelines below.  Use HiHo.c and
conc.c to get ideas on specifics.

We will discuss this in class.

As I announced earlier, phase 2 will involve getting robots to
walk both directions through the corridor without colliding.
Also you will be graded on how well you optimize throughput.

Phase 3 will extend the solution so that it guarantees bounded
waiting.

Satisfaction of the progress condition is required for all the
phases.

Robots cannot back up or jump over cells.  All solutions of all
phases must guarantee that no two robots ever occupy the same
cell in the corridor at the same time.  

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DUE DATE
E-mail your "robot walking program" by midnight on Monday, November 3.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

You can work in a team of two persons on this project if you
want to.  Each team need turn in only one version of each phase
of the program.
=================================================================
Idea for Robots Walking Program

VARIABLES:
corridor : array [0..15] of semaphore ;

MAIN Program:
Begin
  Initialize Data Structures
  For index := 1 to 50 do
  begin
    wait a random time interval (busy wait is OK);
    spawn a robot child, and have it walk the corridor in the
    direction 0 to 15 (WalkNorth(index));
  end ;
End.

PROCEDURE to Initialize Data Structures:
Begin
  For index := 0 to 15 do
    create corridor[index] with initial value = 1 ;
End ;

PROCEDURE to WalkNorth(myNumber):
Begin
  wait a random time interval (busy wait is OK);
  wait(corridor[0]) ;
  Lock standard output ;
  Writeln('Child #', myNumber, ' is starting to walk the corridor.') ;
  Unlock standard output ;  
  For index := 0 to 14 do
  begin
    wait a random time interval (busy wait is OK);
    wait(corridor[index+1]) ;
    signal(corridor[index]) ;
  end ;
  wait a random time interval (busy wait is OK);
  Lock standard output ;
  Writeln('Child #', myNumber, ' has finished walking the corridor.') ;
  Unlock standard output ;  
  signal(corridor[15]) ;
End ;
							  

