producers-consumers/src/consumer.c

32 lines
611 B
C
Raw Normal View History

2022-10-11 19:53:52 -05:00
#include "consumer.h"
2022-10-12 15:44:12 -05:00
#include "shared.h"
2022-10-11 19:53:52 -05:00
2022-10-12 22:59:06 -05:00
// Consumer main function
// TODO: Add waiting for one consumer at a time
// Add ability to use shared memory
2022-10-12 21:11:15 -05:00
void* Consumer(void* arg)
2022-10-11 20:18:38 -05:00
{
2022-10-12 21:11:15 -05:00
long int consumeNum;
2022-10-11 20:18:38 -05:00
while (1)
{
2022-10-12 15:44:12 -05:00
// down(&full);
// down(&mutex);
2022-10-12 21:11:15 -05:00
consumeNum = remove_item();
2022-10-12 15:44:12 -05:00
// up(&mutex);
// up(&empty);
2022-10-12 21:11:15 -05:00
consume_item(consumeNum);
2022-10-12 15:44:12 -05:00
break;
2022-10-11 20:18:38 -05:00
}
}
2022-10-12 22:59:06 -05:00
// Manage item taken from shared memory
2022-10-12 15:44:12 -05:00
void consume_item(long int item)
2022-10-11 20:18:38 -05:00
{
;
}
2022-10-12 22:59:06 -05:00
// Take item out of shared memory
2022-10-11 20:18:38 -05:00
long int remove_item()
2022-10-11 19:50:07 -05:00
{
;
}