Removed commented code and added README.md

This commit is contained in:
TriantaTV 2022-10-15 22:54:10 -05:00
parent 8540de1cd9
commit e920516382
3 changed files with 14 additions and 16 deletions

View File

@ -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

14
README.md Normal file
View File

@ -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

View File

@ -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;
}