int pthread_mutex_init(pthread_mutex_t *Handle, pthread_mutexattr_t *Attributs);
Un événement sert à synchroniser plusieurs threads d'un même processus.
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
pthread_mutexattr_t Attributs;
pthread_t Handle;
...
Attribut.is_initialized=0;
Attribut.process_shared=0;
Attribut.prio_ceiling=0;
Attribut.prio_protect=PTHREAD_PRIO_PROTECT;
Attribut.recursive=0;
if (pthread_mutex_init(&Handle, &Attributs)==-1)
{
...
}
...
if (pthread_mutex_lock(&Handle)==-1)
{
...
}
...
if (pthread_mutex_unlock(&Handle)==-1)
{
...
}
...
if (pthread_mutex_destroy(&Handle)==-1)
{
...
}
...