sem.h 1.9 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3
#ifndef _LINUX_SEM_H
#define _LINUX_SEM_H

A
Arun Sharma 已提交
4
#include <linux/atomic.h>
5
#include <linux/rcupdate.h>
6
#include <linux/cache.h>
7
#include <uapi/linux/sem.h>
L
Linus Torvalds 已提交
8

9 10
struct task_struct;

11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/* 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;

L
Linus Torvalds 已提交
30 31
/* One sem_array data structure for each set of semaphores in the system. */
struct sem_array {
32
	struct kern_ipc_perm	sem_perm;	/* permissions .. see ipc.h */
L
Linus Torvalds 已提交
33
	time_t			sem_ctime;	/* last change time */
34 35 36 37
	struct list_head	pending_alter;	/* pending operations */
						/* that alter the array */
	struct list_head	pending_const;	/* pending complex operations */
						/* that do not alter semvals */
38
	struct list_head	list_id;	/* undo requests on this array */
39 40
	int			sem_nsems;	/* no. of semaphores in array */
	int			complex_count;	/* pending complex operations */
M
Manfred Spraul 已提交
41
	unsigned int		use_global_lock;/* >0: global lock required */
42 43

	struct sem		sems[];
L
Linus Torvalds 已提交
44 45
};

46 47
#ifdef CONFIG_SYSVIPC

L
Linus Torvalds 已提交
48 49 50 51 52 53 54 55
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
56 57 58 59 60

struct sysv_sem {
	/* empty */
};

L
Linus Torvalds 已提交
61 62 63 64 65 66 67 68 69 70 71 72
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 */