sem.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef SEM_H
  2. #define SEM_H
  3. #include <sys/types.h>
  4. #include <sys/ipc.h>
  5. #include <sys/sem.h>
  6. #include "constante.h"
  7. typedef struct{
  8. /* Id retourner par semget */
  9. int id;
  10. /* Clef d'acces au semaphores */
  11. key_t key;
  12. /* Nombre de semaphore */
  13. int nb;
  14. }semaphore;
  15. /**
  16. * Creation d'un tableau de semaphores
  17. * @param semaphore* Le tableau de semaphore
  18. * @param int La clef
  19. * @param int Le nombre semaphores
  20. * @param int* Valeur à initialiser
  21. * @return boolean Reussite
  22. */
  23. boolean create_sem(semaphore*, int, int, int*);
  24. /**
  25. * Récuperation d'un tableau de semaphores
  26. * @param semaphore* Le tableau de semaphore
  27. * @param int La clef
  28. * @return boolean Reussite
  29. */
  30. boolean get_sem(semaphore*, int);
  31. /**
  32. * Demande l'acces et decremente le semaphore (Puis je)
  33. * @param semaphore* Le tableau de semaphore
  34. * @param int Le numero de la semaphore
  35. * @return boolean Reussite
  36. */
  37. boolean P(semaphore*, int);
  38. /**
  39. * Augmente le compteur d'une semaphore (Vas y)
  40. * @param semaphore* Le tableau de semaphore
  41. * @param int Le numero de la semaphore
  42. * @return boolean Reussite
  43. */
  44. boolean V(semaphore*, int);
  45. /**
  46. * Supprime un tableau de semaphores
  47. * @param semaphore* Le tableau de semaphore
  48. * @return boolean Reussite
  49. */
  50. boolean delete_sem(semaphore*);
  51. #endif