|
DS 7 - Semaphores
|
Thread specific informations for consumer and producer threads. More...
Data Fields | |
| char * | buf |
| The shared buffer. | |
| int | buf_size |
| holds the size of the shared ring buffer | |
| sem_t * | open_sem |
| This semaphore holds the number of free locations. | |
| sem_t * | ready_sem |
| This semaphore holds the number of ready locations. | |
Thread specific informations for consumer and producer threads.
This structure is used to instruct the thread about where is the shared buffer and the semaphore to use.
| arg_t::buf |
The shared buffer.
Producers will fill locations in this buffer, while consumers will read and print the bytes in the buffer.
| arg_t::buf_size |
holds the size of the shared ring buffer
This variable stores the size of the shared ring buffer
| arg_t::open_sem |
This semaphore holds the number of free locations.
This semaphore is used by the producer to produce a new byte in the shared buffer. It will be used by the consumer to notify that a byte has been consumed from the buffer.
| arg_t::ready_sem |
This semaphore holds the number of ready locations.
This semaphore is used by the producer to notify that a new byte in the shared buffer has been produced. It will be used by the consumer to understand that a byte can be consumed from the buffer.