diff options
author | Matthew Wilcox <matthew@wil.cx> | 2008-04-11 15:23:52 -0400 |
---|---|---|
committer | Matthew Wilcox <willy@linux.intel.com> | 2008-04-17 10:43:01 -0400 |
commit | 714493cd5468f42ca3c4f730a9c17c203abd5059 (patch) | |
tree | 9d087ad3b74cb1bd6fbd9be486fc2b361c6407dd /include/linux/semaphore.h | |
parent | b17170b2fac96705db3188f093f89e8e838418e4 (diff) |
Improve semaphore documentation
Move documentation from semaphore.h to semaphore.c as requested by
Andrew Morton. Also reformat to kernel-doc style and add some more
notes about the implementation.
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Diffstat (limited to 'include/linux/semaphore.h')
-rw-r--r-- | include/linux/semaphore.h | 39 |
1 files changed, 2 insertions, 37 deletions
diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h index a7125daaff9..9cae64b00d6 100644 --- a/include/linux/semaphore.h +++ b/include/linux/semaphore.h | |||
@@ -4,8 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Distributed under the terms of the GNU GPL, version 2 | 5 | * Distributed under the terms of the GNU GPL, version 2 |
6 | * | 6 | * |
7 | * Counting semaphores allow up to <n> tasks to acquire the semaphore | 7 | * Please see kernel/semaphore.c for documentation of these functions |
8 | * simultaneously. | ||
9 | */ | 8 | */ |
10 | #ifndef __LINUX_SEMAPHORE_H | 9 | #ifndef __LINUX_SEMAPHORE_H |
11 | #define __LINUX_SEMAPHORE_H | 10 | #define __LINUX_SEMAPHORE_H |
@@ -13,11 +12,7 @@ | |||
13 | #include <linux/list.h> | 12 | #include <linux/list.h> |
14 | #include <linux/spinlock.h> | 13 | #include <linux/spinlock.h> |
15 | 14 | ||
16 | /* | 15 | /* Please don't access any members of this structure directly */ |
17 | * The spinlock controls access to the other members of the semaphore. | ||
18 | * 'count' represents how many more tasks can acquire this semaphore. | ||
19 | * Tasks waiting for the lock are kept on the wait_list. | ||
20 | */ | ||
21 | struct semaphore { | 16 | struct semaphore { |
22 | spinlock_t lock; | 17 | spinlock_t lock; |
23 | unsigned int count; | 18 | unsigned int count; |
@@ -46,41 +41,11 @@ static inline void sema_init(struct semaphore *sem, int val) | |||
46 | #define init_MUTEX(sem) sema_init(sem, 1) | 41 | #define init_MUTEX(sem) sema_init(sem, 1) |
47 | #define init_MUTEX_LOCKED(sem) sema_init(sem, 0) | 42 | #define init_MUTEX_LOCKED(sem) sema_init(sem, 0) |
48 | 43 | ||
49 | /* | ||
50 | * Attempt to acquire the semaphore. If another task is already holding the | ||
51 | * semaphore, sleep until the semaphore is released. | ||
52 | */ | ||
53 | extern void down(struct semaphore *sem); | 44 | extern void down(struct semaphore *sem); |
54 | |||
55 | /* | ||
56 | * As down(), except the sleep may be interrupted by a signal. If it is, | ||
57 | * this function will return -EINTR. | ||
58 | */ | ||
59 | extern int __must_check down_interruptible(struct semaphore *sem); | 45 | extern int __must_check down_interruptible(struct semaphore *sem); |
60 | |||
61 | /* | ||
62 | * As down_interruptible(), except the sleep may only be interrupted by | ||
63 | * signals which are fatal to this process. | ||
64 | */ | ||
65 | extern int __must_check down_killable(struct semaphore *sem); | 46 | extern int __must_check down_killable(struct semaphore *sem); |
66 | |||
67 | /* | ||
68 | * As down(), except this function will not sleep. It will return 0 if it | ||
69 | * acquired the semaphore and 1 if the semaphore was contended. This | ||
70 | * function may be called from any context, including interrupt and softirq. | ||
71 | */ | ||
72 | extern int __must_check down_trylock(struct semaphore *sem); | 47 | extern int __must_check down_trylock(struct semaphore *sem); |
73 | |||
74 | /* | ||
75 | * As down(), except this function will return -ETIME if it fails to | ||
76 | * acquire the semaphore within the specified number of jiffies. | ||
77 | */ | ||
78 | extern int __must_check down_timeout(struct semaphore *sem, long jiffies); | 48 | extern int __must_check down_timeout(struct semaphore *sem, long jiffies); |
79 | |||
80 | /* | ||
81 | * Release the semaphore. Unlike mutexes, up() may be called from any | ||
82 | * context and even by tasks which have never called down(). | ||
83 | */ | ||
84 | extern void up(struct semaphore *sem); | 49 | extern void up(struct semaphore *sem); |
85 | 50 | ||
86 | #endif /* __LINUX_SEMAPHORE_H */ | 51 | #endif /* __LINUX_SEMAPHORE_H */ |