sem.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef _LINUX_SEM_H
  2. #define _LINUX_SEM_H
  3. #include <linux/atomic.h>
  4. #include <linux/rcupdate.h>
  5. #include <linux/cache.h>
  6. #include <uapi/linux/sem.h>
  7. struct task_struct;
  8. /* One semaphore structure for each semaphore in the system. */
  9. struct sem {
  10. int semval; /* current value */
  11. /*
  12. * PID of the process that last modified the semaphore. For
  13. * Linux, specifically these are:
  14. * - semop
  15. * - semctl, via SETVAL and SETALL.
  16. * - at task exit when performing undo adjustments (see exit_sem).
  17. */
  18. int sempid;
  19. spinlock_t lock; /* spinlock for fine-grained semtimedop */
  20. struct list_head pending_alter; /* pending single-sop operations */
  21. /* that alter the semaphore */
  22. struct list_head pending_const; /* pending single-sop operations */
  23. /* that do not alter the semaphore*/
  24. time_t sem_otime; /* candidate for sem_otime */
  25. } ____cacheline_aligned_in_smp;
  26. /* One sem_array data structure for each set of semaphores in the system. */
  27. struct sem_array {
  28. struct kern_ipc_perm sem_perm; /* permissions .. see ipc.h */
  29. time_t sem_ctime; /* create/last semctl() time */
  30. struct list_head pending_alter; /* pending operations */
  31. /* that alter the array */
  32. struct list_head pending_const; /* pending complex operations */
  33. /* that do not alter semvals */
  34. struct list_head list_id; /* undo requests on this array */
  35. int sem_nsems; /* no. of semaphores in array */
  36. int complex_count; /* pending complex operations */
  37. unsigned int use_global_lock;/* >0: global lock required */
  38. struct sem sems[];
  39. };
  40. #ifdef CONFIG_SYSVIPC
  41. struct sysv_sem {
  42. struct sem_undo_list *undo_list;
  43. };
  44. extern int copy_semundo(unsigned long clone_flags, struct task_struct *tsk);
  45. extern void exit_sem(struct task_struct *tsk);
  46. #else
  47. struct sysv_sem {
  48. /* empty */
  49. };
  50. static inline int copy_semundo(unsigned long clone_flags, struct task_struct *tsk)
  51. {
  52. return 0;
  53. }
  54. static inline void exit_sem(struct task_struct *tsk)
  55. {
  56. return;
  57. }
  58. #endif
  59. #endif /* _LINUX_SEM_H */