diff options
author | Matthew Wilcox <matthew@wil.cx> | 2008-03-14 14:35:22 -0400 |
---|---|---|
committer | Matthew Wilcox <willy@linux.intel.com> | 2008-04-17 10:42:54 -0400 |
commit | b17170b2fac96705db3188f093f89e8e838418e4 (patch) | |
tree | 3264d8a297cff20338b606559274c36fbf663f04 /include/linux/semaphore.h | |
parent | f1241c87a16c4fe9f4f51d6ed3589f031c505e8d (diff) |
Simplify semaphore implementation
By removing the negative values of 'count' and relying on the wait_list to
indicate whether we have any waiters, we can simplify the implementation
by removing the protection against an unlikely race condition. Thanks to
David Howells for his suggestions.
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Diffstat (limited to 'include/linux/semaphore.h')
-rw-r--r-- | include/linux/semaphore.h | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h index a107aebd9148..a7125daaff90 100644 --- a/include/linux/semaphore.h +++ b/include/linux/semaphore.h | |||
@@ -15,15 +15,12 @@ | |||
15 | 15 | ||
16 | /* | 16 | /* |
17 | * The spinlock controls access to the other members of the semaphore. | 17 | * The spinlock controls access to the other members of the semaphore. |
18 | * 'count' is decremented by every task which calls down*() and incremented | 18 | * 'count' represents how many more tasks can acquire this semaphore. |
19 | * by every call to up(). Thus, if it is positive, it indicates how many | 19 | * Tasks waiting for the lock are kept on the wait_list. |
20 | * more tasks may acquire the lock. If it is negative, it indicates how | ||
21 | * many tasks are waiting for the lock. Tasks waiting for the lock are | ||
22 | * kept on the wait_list. | ||
23 | */ | 20 | */ |
24 | struct semaphore { | 21 | struct semaphore { |
25 | spinlock_t lock; | 22 | spinlock_t lock; |
26 | int count; | 23 | unsigned int count; |
27 | struct list_head wait_list; | 24 | struct list_head wait_list; |
28 | }; | 25 | }; |
29 | 26 | ||