2022-10-11 19:50:07 -05:00
|
|
|
#include <stdio.h>
|
2022-10-12 21:11:15 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/shm.h>
|
|
|
|
#include <time.h>
|
2022-10-11 19:50:07 -05:00
|
|
|
#include <unistd.h>
|
2022-10-12 15:44:12 -05:00
|
|
|
#include "consumer.h"
|
|
|
|
#include "producer.h"
|
|
|
|
#include "shared.h"
|
2022-10-11 20:18:38 -05:00
|
|
|
|
2022-10-11 19:50:07 -05:00
|
|
|
int GetSplitAmount(char* argv);
|
2022-10-12 21:11:15 -05:00
|
|
|
void TestProducerConsumer(void);
|
2022-10-11 19:50:07 -05:00
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
2022-10-12 21:11:15 -05:00
|
|
|
srand(time(NULL));
|
2022-10-12 15:44:12 -05:00
|
|
|
sharedMem testMemory;
|
|
|
|
|
2022-10-11 19:50:07 -05:00
|
|
|
int splitLimit = 1;
|
|
|
|
if (argc == 2)
|
|
|
|
splitLimit = GetSplitAmount(argv[1]);
|
2022-10-12 21:11:15 -05:00
|
|
|
TestProducerConsumer();
|
2022-10-11 19:50:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int GetSplitAmount(char* argv)
|
|
|
|
{
|
|
|
|
int splitAmount;
|
|
|
|
sscanf(argv, "%d", &splitAmount);
|
|
|
|
return splitAmount;
|
|
|
|
}
|
2022-10-12 21:11:15 -05:00
|
|
|
|
|
|
|
void TestProducerConsumer(void)
|
|
|
|
{
|
|
|
|
Producer(NULL);
|
|
|
|
Consumer(NULL);
|
|
|
|
}
|