Esempio n. 1
0
void *oneVehicle(void *vargp) {
  Car *car = (Car *)vargp;

  arriveBridge(car);
  onBridge(car);
  exitBridge(car);

  return NULL;
}
Esempio n. 2
0
/*
 Main method for each thread.
 */
void *oneCar(void *direction_name_sleep_void_pointer) {
  DirectionNameSleep *direction_name_sleep = (DirectionNameSleep *)direction_name_sleep_void_pointer;

  int direction = direction_name_sleep->direction;
  int name = direction_name_sleep->name;
  float sleep_duration = direction_name_sleep->sleep_duration;

  arriveBridge(direction, name); // Now the car is on the bridge.

  TracePrintf(TRACE_LEVEL_TESTING_OUTPUT, "~~~ %d: Delaying for %d.\n", name, sleep_duration);
  Delay(sleep_duration);

  onBridge(direction, name);

  TracePrintf(TRACE_LEVEL_TESTING_OUTPUT, "~~~ %d: Delaying for %d.\n", name, sleep_duration);
  Delay(sleep_duration);

  exitBridge(direction, name); // Now the car is off the bridge.

  return NULL;
}