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