32 flights must land at, be serviced by, and take off from, an airport. All flights that approach the airport go to a 20,000 holding pattern, which can accomodate all of the flights simultaneously. However, as they approach to land, they go thru 4 different flight areas. Each flight area can hold its own maximum number of flights, and must be visited in the given order:
Flight Area:Number of
simultaneous flights:10000 ft holding pattern3Landing Runway1Terminal4Take off Runway1
Note: some flight areas can hold multiple flights. Therefore, we do not want to lock the flight area. Rather, we want to lock the enter()-ing and leave()-ing of the flight area.
Make main() create NUM_FLIGHTS pthreads. Each pthread will run fly() given the address of one of the NUM_FLIGHTS instances of Flight in array flights. Afterwards, main()should wait for all NUM_FLIGHTS pthreads. Because fly() does not return any meaningful value, the second argument to pthread_join() can just be NULL.
Write void* fly (void* vPtr). fly() must cast the incoming vPtr to a pointer of type Flight, then run method doFlight() on that Flight instance. (You can say something like oHare.doFlight(*flightPtr)) Finally, it should return NULL
Finish the enter() method of class FlightArea. Do not disturb the code that is already there, but make it thread safe by locking the method as you begin, unlocking it as you leave, and waiting if the FlightArea is full.
Finish the leave() method of class FlightArea. Again, do not disturb the code that is already there, but make it thread safe by locking the method as you begin, unlocking it as you leave, and signalling that another Flight may enter.
Of course you may have add member variables to class FlightArea, and initialize and kill them in the constructor and destructor respectively.