2022-10-11 20:18:38 -05:00
|
|
|
#include <stdlib.h>
|
2022-10-11 19:53:52 -05:00
|
|
|
#include "producer.h"
|
2022-10-12 15:44:12 -05:00
|
|
|
#include "shared.h"
|
2022-10-11 19:53:52 -05:00
|
|
|
|
|
|
|
void Producer(void)
|
2022-10-11 20:18:38 -05:00
|
|
|
{
|
|
|
|
int item;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
item = produce_item();
|
2022-10-12 15:44:12 -05:00
|
|
|
// sem_wait(&semProducer);
|
|
|
|
// down(&empty);
|
|
|
|
// down(&mutex);
|
2022-10-11 20:18:38 -05:00
|
|
|
insert_item(item);
|
2022-10-12 15:44:12 -05:00
|
|
|
// sem_post(&semProducer);
|
|
|
|
// up(&mutex);
|
|
|
|
// up(&full);
|
|
|
|
break;
|
2022-10-11 20:18:38 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
long int produce_item(void)
|
|
|
|
{
|
|
|
|
return random();
|
|
|
|
}
|
|
|
|
|
2022-10-12 15:44:12 -05:00
|
|
|
void insert_item(long int item)
|
2022-10-11 19:50:07 -05:00
|
|
|
{
|
|
|
|
;
|
|
|
|
}
|