//------------------------------------------------------------------------ // Filename: // bridge-mon.h // PROGRAM DESCRIPTION // class definition file for BridgeMonitor class // // MONITOR bridge, Hoare style: // This monitor solves the bridge-crossing problem. It consists // of the following procedures: // (1) BridgeInit() - initialize bridge // (2) ArriveBridge() - called when a vehicle arrives at the // bridge // (3) ExitBridge() - called when a vehicle exits the bridge // ---------------------------------------------------------------- #ifndef _BRIDGE_MON_H #define _BRIDGE_MON_H #include "ThreadClass.h" //------------------------------------------------------------------------ // BridgeMonitor class definition //------------------------------------------------------------------------ class BridgeMonitor: public Monitor { public: BridgeMonitor(char* Name); // constructor int isSafe(int Direction); void ArriveBridge(int Direction); void ExitBridge(int Direction); private: Condition *WaitingLine[2]; // blocks vehicles int CurrentDirection; // current direction of cars int VehicleCount; // # of vehicle on the bridge int Waiting[2]; // # of east/west bound waiting char *Names[2]; }; #endif