2005-04-16 15:20:36 -07:00
|
|
|
#ifndef _LINUX_SEM_H
|
|
|
|
|
#define _LINUX_SEM_H
|
|
|
|
|
|
2011-07-26 16:09:06 -07:00
|
|
|
#include <linux/atomic.h>
|
2008-07-25 01:48:06 -07:00
|
|
|
#include <linux/rcupdate.h>
|
2010-05-26 14:43:42 -07:00
|
|
|
#include <linux/cache.h>
|
2017-08-02 19:51:13 -07:00
|
|
|
#include <linux/time64.h>
|
2012-10-13 10:46:48 +01:00
|
|
|
#include <uapi/linux/sem.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2005-11-07 00:59:43 -08:00
|
|
|
struct task_struct;
|
|
|
|
|
|
2017-07-12 14:34:38 -07:00
|
|
|
/* One semaphore structure for each semaphore in the system. */
|
|
|
|
|
struct sem {
|
|
|
|
|
int semval; /* current value */
|
|
|
|
|
/*
|
|
|
|
|
* PID of the process that last modified the semaphore. For
|
|
|
|
|
* Linux, specifically these are:
|
|
|
|
|
* - semop
|
|
|
|
|
* - semctl, via SETVAL and SETALL.
|
|
|
|
|
* - at task exit when performing undo adjustments (see exit_sem).
|
|
|
|
|
*/
|
|
|
|
|
int sempid;
|
|
|
|
|
spinlock_t lock; /* spinlock for fine-grained semtimedop */
|
|
|
|
|
struct list_head pending_alter; /* pending single-sop operations */
|
|
|
|
|
/* that alter the semaphore */
|
|
|
|
|
struct list_head pending_const; /* pending single-sop operations */
|
|
|
|
|
/* that do not alter the semaphore*/
|
|
|
|
|
time_t sem_otime; /* candidate for sem_otime */
|
|
|
|
|
} ____cacheline_aligned_in_smp;
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/* One sem_array data structure for each set of semaphores in the system. */
|
|
|
|
|
struct sem_array {
|
2017-05-08 15:57:06 -07:00
|
|
|
struct kern_ipc_perm sem_perm; /* permissions .. see ipc.h */
|
2017-08-02 19:51:13 -07:00
|
|
|
time64_t sem_ctime; /* create/last semctl() time */
|
2013-07-08 16:01:23 -07:00
|
|
|
struct list_head pending_alter; /* pending operations */
|
|
|
|
|
/* that alter the array */
|
|
|
|
|
struct list_head pending_const; /* pending complex operations */
|
|
|
|
|
/* that do not alter semvals */
|
2008-07-25 01:48:04 -07:00
|
|
|
struct list_head list_id; /* undo requests on this array */
|
2009-12-15 16:47:32 -08:00
|
|
|
int sem_nsems; /* no. of semaphores in array */
|
|
|
|
|
int complex_count; /* pending complex operations */
|
2017-02-27 14:28:18 -08:00
|
|
|
unsigned int use_global_lock;/* >0: global lock required */
|
2017-07-12 14:34:38 -07:00
|
|
|
|
|
|
|
|
struct sem sems[];
|
2016-10-28 01:22:25 -07:00
|
|
|
} __randomize_layout;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2011-11-02 13:38:56 -07:00
|
|
|
#ifdef CONFIG_SYSVIPC
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
struct sysv_sem {
|
|
|
|
|
struct sem_undo_list *undo_list;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern int copy_semundo(unsigned long clone_flags, struct task_struct *tsk);
|
|
|
|
|
extern void exit_sem(struct task_struct *tsk);
|
|
|
|
|
|
|
|
|
|
#else
|
2011-11-02 13:38:56 -07:00
|
|
|
|
|
|
|
|
struct sysv_sem {
|
|
|
|
|
/* empty */
|
|
|
|
|
};
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
static inline int copy_semundo(unsigned long clone_flags, struct task_struct *tsk)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void exit_sem(struct task_struct *tsk)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /* _LINUX_SEM_H */
|