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