diff --git a/G17_bykes/main.c b/G17_bykes/main.c index f8adf0c2bc030837b6e706902eba71b7d00a71a1..0cf8bcdc231d882b91e53672b19b54a54979b84d 100644 --- a/G17_bykes/main.c +++ b/G17_bykes/main.c @@ -13,6 +13,8 @@ #define DEPOT 0 +#define USLEEP 0 + sem_t *sem_FreeSlot; sem_t *sem_BikeFree; pthread_mutex_t *mutex; @@ -195,8 +197,9 @@ void *civilians(void *arg){ do{ j = (rand()%(hab->nbcitiess - 1))+1; }while(j==hab->i_cities); +#if USLEEP usleep(rand_D()); - +#endif //waits for a parkinglot to be freed and deposit his bycycle //if(j==4){ @@ -228,7 +231,9 @@ void *civilians(void *arg){ //} //does whatever he has to do for a D delay time (waits for rand() 1000->1999us) +#if USLEEP usleep(rand_D()); +#endif //changes his position from cities i = j (j is the new cities) hab->i_cities = j; hab->nb_trajet += 1; @@ -312,8 +317,10 @@ void *trucks(void *arg){ pthread_mutex_unlock(&mutex[DEPOT]); } //3: pause betweem 100us up to 199us +#if USLEEP usleep(rand_Dc()); - printf("TRUCK new loop, person's threads finished: %d\n", personsFinished); +#endif + //printf("TRUCK new loop, person's threads finished: %d\n", personsFinished); } printf("TRUCK end loop\n"); return NULL;