Reader Writer Problem

This commit is contained in:
2023-04-05 14:32:43 +02:00
parent 9ee8f961b3
commit 2e796b1d83
9 changed files with 823 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
/* Ensemble de macros bien pratiques pour les moniteurs pthreads */
#ifndef _MACROS_THREADS_H_
#define _MACROS_THREADS_H_
/* Mutex */
#define INIT_MUTEX(unMutex) if (pthread_mutex_init(&(unMutex), NULL)) { perror("pthread_mutex_init (&(unMutex), NULL)"); pthread_exit(NULL);}
#define P_MUTEX(unMutex) if (pthread_mutex_lock(&(unMutex))) { perror("pthread_mutex_lock(&(unMutex))"); pthread_exit(NULL);}
#define V_MUTEX(unMutex) if (pthread_mutex_unlock(&(unMutex))) { perror("pthread_mutex_unlock(&(unMutex))"); pthread_exit(NULL);}
#define DESTROY_MUTEX(unMutex) if (pthread_mutex_destroy(&(unMutex))) { perror("pthread_mutex_destroy(&(unMutex))"); pthread_exit(NULL);}
/* Conditions */
#define INIT_COND(uneCondition) if (pthread_cond_init(&(uneCondition), NULL)) { perror("pthread_cond_init(&(uneCondition), NULL)"); pthread_exit(NULL);}
#define WAIT_COND(uneCondition,unMutex) if (pthread_cond_wait(&(uneCondition), &(unMutex))) { perror("pthread_cond_wait(&(uneCondition), &(unMutex))"); pthread_exit(NULL);}
#define SIGNAL_COND(uneCondition) if (pthread_cond_signal(&(uneCondition))) { perror("pthread_cond_signal(&(uneCondition))"); pthread_exit(NULL);}
#define DESTROY_COND(uneCondition) if (pthread_cond_destroy(&(uneCondition))) { perror("pthread_cond_destroy(&(uneCondition))"); pthread_exit(NULL);}
#endif