From e920516382f81f4c01cea4530b742f3d6bc905b2 Mon Sep 17 00:00:00 2001 From: TriantaTV Date: Sat, 15 Oct 2022 22:54:10 -0500 Subject: [PATCH] Removed commented code and added README.md --- Makefile | 4 ---- README.md | 14 ++++++++++++++ src/consumer.c | 12 ------------ 3 files changed, 14 insertions(+), 16 deletions(-) create mode 100644 README.md diff --git a/Makefile b/Makefile index fc7cb00..1a2f1cb 100644 --- a/Makefile +++ b/Makefile @@ -13,10 +13,6 @@ link: gcc -o bin/producer.out build/producer.o build/shared.o gcc -o bin/consumer.out build/consumer.o build/shared.o - -exec: compile link - ./bin/driver.out - clean: rm build/*.o rm bin/*.out diff --git a/README.md b/README.md new file mode 100644 index 0000000..d763136 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +#Producer-Consumer +Made by: Gregory Crawford (gcrawfo@siue.edu) + +#Compiling: +Open root folder where `Makefile` is located. +Type `make` and the program should compile to the `./bin` folder + +#Usage: +## Important! Must be in the bin folder for this to work +./driver.out [-p] [-c] + +#Arguments: +[-p] -- Enter a specific number of producers +[-c] -- Enter a specific number of consumers \ No newline at end of file diff --git a/src/consumer.c b/src/consumer.c index 228233d..4a8fb45 100644 --- a/src/consumer.c +++ b/src/consumer.c @@ -68,25 +68,13 @@ int GetNextUsedSlot(SharedStruct* sharedMem) void SemaphoreCleanup(SharedStruct* sharedMem) { int semMath = 2*(sharedMem->consumerCount) + (sharedMem->producerCount) - 1; - // int semCheckMutex; int semCheckEmpty; - // int semCheckFull; - // sem_getvalue(&sharedMem->mutex, &semCheckMutex); sem_getvalue(&sharedMem->empty, &semCheckEmpty); - // sem_getvalue(&sharedMem->full, &semCheckFull); - // if (semCheckMutex > 0) - // sem_post(&sharedMem->mutex); if (semCheckEmpty < semMath) { sem_post(&sharedMem->full); exit(0); } - // sem_post(&sharedMem->empty); - // if (semCheckFull > 0) - // sem_post(&sharedMem->full); - // printf("Value of semCheckMutex: %d\n", semCheckMutex); - // printf("Value of semCheckEmpty: %d\n", semCheckEmpty); - // printf("Value of semCheckFull: %d\n", semCheckFull); return; }