Listing 1 Definition for semaphore class

//****************************************************
//  Listing 1
//
//  FILE NAME   : sema.h
//  AUTHOR      : Matt Weisfeld
//
//  DESCRIPTION : definition for semaphore class
//**************************************************
#ifndef SEMAPHORE_H
#define SEMAPHORE_H

#include <stdio.h>
#include "defines.h"

class semaphore {
private:
   long PROCESSES;                  // number of processes
   long NODE[MAX_NODES];            // array of nodes
   long LOC[MAX_NODES];             // array of locations
   long NODE_NUM[MAX_NODES];        // array of node numbers
   long i,j,node,turn_num,flag_num; // corresponding alogorithm
                              // vars
   char filename[FILE_LENGTH];      // shared data file
   long critical_status;            // status variable for
                              // critical sections
public:
   semaphore (long);         // constructor
   ~semaphore(void);         // destructor
   void synchronize(char *);          // synchronize using
                                // critical sections
   void perform(void);             // contains the CS algorithm
   void intro(void);               // identify the node
   void cs_write(long,long);       // write to the shared file
   long cs_read(long);             // read from the shared file
   long critical_section(void);    // actual critical section
   void initialize(void);    // initialize the shared data file
};
#endif
/* End of File */