Skip to content
Snippets Groups Projects
Commit 23ffb458 authored by ismail.abloua's avatar ismail.abloua
Browse files

web push

parent 2d8beed7
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,7 @@ void habitant_routine(void* arg) {
int destination_site;
do {destination_site = rand() % S;}
while (destination_site == current_site);
current_site = destination_site;
// return bike to destination site
sem_wait(&sites[current_site].sem_slots);
......@@ -96,10 +97,17 @@ void truck_routine() {
pthread_mutex_unlock(&sites[i].site_mutex);
}
// refill depot routine
while(truck > 2) {
printf("(DEPOT) Truck returning to depot (%d bikes in truck)\n", truck);
truck--;
depot++;
}
while(truck < 2 && depot > 0) {
printf("(DEPOT) Truck returning to depot (%d bikes in truck)\n", truck);
depot--;
truck++;
}
}
}
......@@ -190,5 +198,5 @@ int main(int argc, char* argv[]) {
pthread_mutex_destroy(&mutex_finished_habitants);
pthread_mutex_destroy(&mutex_finished_habitants);
EXIT_SUCCESS;
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment