Blame view
include/linux/semaphore.h
1.36 KB
64ac24e73 Generic semaphore... |
1 2 3 4 5 6 |
/* * Copyright (c) 2008 Intel Corporation * Author: Matthew Wilcox <willy@linux.intel.com> * * Distributed under the terms of the GNU GPL, version 2 * |
714493cd5 Improve semaphore... |
7 |
* Please see kernel/semaphore.c for documentation of these functions |
64ac24e73 Generic semaphore... |
8 9 10 11 12 13 |
*/ #ifndef __LINUX_SEMAPHORE_H #define __LINUX_SEMAPHORE_H #include <linux/list.h> #include <linux/spinlock.h> |
714493cd5 Improve semaphore... |
14 |
/* Please don't access any members of this structure directly */ |
64ac24e73 Generic semaphore... |
15 |
struct semaphore { |
8292c9e15 locking, semaphor... |
16 |
raw_spinlock_t lock; |
b17170b2f Simplify semaphor... |
17 |
unsigned int count; |
64ac24e73 Generic semaphore... |
18 19 20 21 22 |
struct list_head wait_list; }; #define __SEMAPHORE_INITIALIZER(name, n) \ { \ |
8292c9e15 locking, semaphor... |
23 |
.lock = __RAW_SPIN_LOCK_UNLOCKED((name).lock), \ |
64ac24e73 Generic semaphore... |
24 25 26 |
.count = n, \ .wait_list = LIST_HEAD_INIT((name).wait_list), \ } |
febc88c59 semaphore: Add DE... |
27 28 |
#define DEFINE_SEMAPHORE(name) \ struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) |
64ac24e73 Generic semaphore... |
29 30 31 32 33 34 |
static inline void sema_init(struct semaphore *sem, int val) { static struct lock_class_key __key; *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val); lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0); } |
64ac24e73 Generic semaphore... |
35 |
extern void down(struct semaphore *sem); |
64ac24e73 Generic semaphore... |
36 |
extern int __must_check down_interruptible(struct semaphore *sem); |
f06d96865 Introduce down_ki... |
37 |
extern int __must_check down_killable(struct semaphore *sem); |
64ac24e73 Generic semaphore... |
38 |
extern int __must_check down_trylock(struct semaphore *sem); |
f1241c87a Add down_timeout ... |
39 |
extern int __must_check down_timeout(struct semaphore *sem, long jiffies); |
64ac24e73 Generic semaphore... |
40 41 42 |
extern void up(struct semaphore *sem); #endif /* __LINUX_SEMAPHORE_H */ |