|
DS 7 - Semaphores
|
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <semaphore.h>#include <pthread.h>Data Structures | |
| struct | arg_t |
| Thread specific informations for consumer and producer threads. More... | |
Macros | |
| #define | BUFFER_SIZE 4 |
| BUFFER_SIZE | |
Functions | |
| void * | producer_thread (void *arg) |
| Producer routine. | |
| void * | consumer_thread (void *arg) |
| Consumerer routine. | |
| int | main (int argc, char **args) |
| Main routine. | |
| #define BUFFER_SIZE 4 |
BUFFER_SIZE
Size in bytes of the shared buffer
This holds the size of the circular buffer shared between producer and consumer
| void* consumer_thread | ( | void * | arg | ) |
Consumerer routine.
This is the routine for the consumer. It consumes one byte at a time from the shared buffer.
| int main | ( | int | argc, |
| char ** | args | ||
| ) |
Main routine.
The main will have to:
| argc | number of parameters |
| args | command line parameters |
| void* producer_thread | ( | void * | arg | ) |
Producer routine.
This is the routine for the producer. It produces one byte at a time and puts it in the shared buffer.