/* Producer */
while(true)
{
if (counter == BUFFER_SIZE)
sleep_on(empty);
buffer[in] = item;
in = (in+1) % BUFFER_SIZE;
counte++;
if (counter == 1)
wake_up(full);
}
/* Producer */
while(true)
{
if (counter == BUFFER_SIZE)
sleep_on(empty);
buffer[in] = item;
in = (in+1) % BUFFER_SIZE;
counte++;
if (counter == 1)
wake_up(full);
}
/* Consumer */
while(true)
{
if (counter == 0)
sleep_on(full);
item = buffer[out];
out = (out+1) % BUFFER_SIZE;
counte--;
if (counter == BUFFER_SIZE - 1)
wake_up(empty);
}
sem_t *sem_open(const char *name, int oflag, mode_t mode, unsigned int value);
int sem_unlink(count char *name);
int sem_wait(sem_t *sem);
int sem_post(sem_t *sem);