From 5418f83caeff1fa1769c05db8e33cdf1c7b4e23a Mon Sep 17 00:00:00 2001 From: Isaac Shoebottom Date: Wed, 11 Oct 2023 17:20:02 -0300 Subject: [PATCH] Change where sleep is --- Assignment3/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Assignment3/main.c b/Assignment3/main.c index 1d43251..978ec17 100644 --- a/Assignment3/main.c +++ b/Assignment3/main.c @@ -41,7 +41,7 @@ void* dweller(void* arg) { int time = RANDOM_WITHIN_RANGE(MIN_TIME_FOR_HOUSE_DWELLER, MAX_TIME_FOR_HOUSE_DWELLER, seed); sleep(time); write(houseFloor[WRITE_END], &weight, sizeof(int)); - printf("House dweller %d produced a box that weights %d in %d units of time\n", id, weight, time); + printf("House dweller %d created a box that weights %d in %d units of time\n", id, weight, time); } printf("House dweller %d is done packing\n", id); free(args); @@ -58,8 +58,8 @@ void* mover(void* arg) { while (read(houseFloor[READ_END], &weight, sizeof(int)) > 0) { int time = RANDOM_WITHIN_RANGE(MIN_TIME_FOR_MOVER, MAX_TIME_FOR_MOVER, seed); sleep(time); - printf("Mover %d brought down a box of weight %d in %d units of time\n", id, weight, time); write(nextToTrucks[WRITE_END], &weight, sizeof(int)); + printf("Mover %d brought down a box of weight %d in %d units of time\n", id, weight, time); } printf("Mover %d is done moving\n", id); free(args); @@ -91,9 +91,9 @@ void* trucker(void* arg) { } } printf("Truck %d is not full\n", id); - int time = RANDOM_WITHIN_RANGE(MIN_TRIP_TIME/2, MAX_TRIP_TIME/2, seed); // One way trip, so half the time - sleep(time); + int time = RANDOM_WITHIN_RANGE(MIN_TRIP_TIME, MAX_TRIP_TIME, seed); // One way trip, so half the time printf("Not full truck %d with load of %d units of mass departed. One way will take %d units of time\n", id, truckWeight, time); + sleep(time); printf("Truck %d is finished\n", id); free(args); return NULL;