A multi-thread program is used to simulate a road with a narrow point. 
In this road, cars can arrive from left or from right. However, only one car at time can pass from the narrow point. A policeman regulates access to the road.

The system consists of N cars, each one is simulated by the following thread, while the policeman is simulated by another thread.

#define FROM_RIGHT    0
#define FROM_LEFT     1

void *car(void *arg)
{
   int dir = (int) arg;    
   
   request_passage(dir);
   pass();
   go_out(dir);
}

Variable arg can have values FROM_RIGHT if the car comes from the right, and FROM_LEFT if the car comes from left. 

The policeman applies the following rules:

1) only one car at time in the narrow passage (function pass());

2) policeman sets the direction, and only cars in that direction can pass, the 
cars in the opposite direction are blocked.

3) policeman can change direction only when no car is in the passage

4) if at some point there are no cars in the current direction, the policeman 
changes direction anyway

5) otherwise, policeman lets maximum MAX_CAR cars in one direction before changing direction

Create the data structure, and write the code for the program.

