/************************************************************ File: main.cc Description: A program that simulates a one-lane bridge and some cars trying to get through it. Author: Dana Vrajitoru Organization: IUSB Date: December 7, 2004 **************************************************************/ #include #include using namespace std; #include #include #include "bridge.h" Bridge_monitor bridge; // Prototypes. void Create_threads(pthread_t *threads, int nr_threads); void Synchronise(pthread_t *threads, int nr_threads); void *Car(void *arg); int main() { int i, nr_threads; bridge.init(); cout << "enter the total number of cars" << endl; cin >> nr_threads; pthread_t *threads = new pthread_t[nr_threads]; Create_threads(threads, nr_threads); Synchronise(threads, nr_threads); } // Creates the threads calling the producer function, then those // calling the consumer function, and to each of them it passes the // pointer to the number of items as the argument. void Create_threads(pthread_t *threads, int nr_threads) { static int *ids; void *arg; ids= new int[nr_threads]; for (int i=0; i