/*
 * semaphore.c - example of declaring and using a semaphore
 */

#include <stdio.h>
#include <pthread.h>
#include <semaphore.h>


int main()
{
    sem_t semaforo;

    printf("Initialization with 1 unit.\n");
    sem_init(&semaforo, 0, 1);

    printf("Esperar.\n");
    sem_wait(&semaforo);

    printf("Assinalar.\n");
    sem_post(&semaforo);

    printf("Destroy the semaphore.\n");
    sem_destroy(&semaforo);

    return 0;
}
