Skip to content
Snippets Groups Projects
Commit 371935d8 authored by remi.greub's avatar remi.greub
Browse files

ajout du define USLEEP

parent 9d0b6185
Branches
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment