Removed commented code and added README.md
This commit is contained in:
parent
8540de1cd9
commit
e920516382
4
Makefile
4
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
|
||||
|
14
README.md
Normal file
14
README.md
Normal 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
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user