-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 31770 b: refs/heads/master c: c4e0511 h: refs/heads/master v: v3
- Loading branch information
Ingo Molnar
authored and
Linus Torvalds
committed
Jul 3, 2006
1 parent
1de14b9
commit 72faa82
Showing
7 changed files
with
110 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 8b3db9c542e18b71d4820da4dd9401ee030feacb | ||
refs/heads/master: c4e05116a2c4d8187127dbf77ab790aa57a47388 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* kernel/rwsem.c: R/W semaphores, public implementation | ||
* | ||
* Written by David Howells (dhowells@redhat.com). | ||
* Derived from asm-i386/semaphore.h | ||
*/ | ||
|
||
#include <linux/types.h> | ||
#include <linux/kernel.h> | ||
#include <linux/module.h> | ||
#include <linux/rwsem.h> | ||
|
||
#include <asm/system.h> | ||
#include <asm/atomic.h> | ||
|
||
/* | ||
* lock for reading | ||
*/ | ||
void down_read(struct rw_semaphore *sem) | ||
{ | ||
might_sleep(); | ||
rwsem_acquire_read(&sem->dep_map, 0, 0, _RET_IP_); | ||
|
||
__down_read(sem); | ||
} | ||
|
||
EXPORT_SYMBOL(down_read); | ||
|
||
/* | ||
* trylock for reading -- returns 1 if successful, 0 if contention | ||
*/ | ||
int down_read_trylock(struct rw_semaphore *sem) | ||
{ | ||
int ret = __down_read_trylock(sem); | ||
|
||
if (ret == 1) | ||
rwsem_acquire_read(&sem->dep_map, 0, 1, _RET_IP_); | ||
return ret; | ||
} | ||
|
||
EXPORT_SYMBOL(down_read_trylock); | ||
|
||
/* | ||
* lock for writing | ||
*/ | ||
void down_write(struct rw_semaphore *sem) | ||
{ | ||
might_sleep(); | ||
rwsem_acquire(&sem->dep_map, 0, 0, _RET_IP_); | ||
|
||
__down_write(sem); | ||
} | ||
|
||
EXPORT_SYMBOL(down_write); | ||
|
||
/* | ||
* trylock for writing -- returns 1 if successful, 0 if contention | ||
*/ | ||
int down_write_trylock(struct rw_semaphore *sem) | ||
{ | ||
int ret = __down_write_trylock(sem); | ||
|
||
if (ret == 1) | ||
rwsem_acquire(&sem->dep_map, 0, 0, _RET_IP_); | ||
return ret; | ||
} | ||
|
||
EXPORT_SYMBOL(down_write_trylock); | ||
|
||
/* | ||
* release a read lock | ||
*/ | ||
void up_read(struct rw_semaphore *sem) | ||
{ | ||
rwsem_release(&sem->dep_map, 1, _RET_IP_); | ||
|
||
__up_read(sem); | ||
} | ||
|
||
EXPORT_SYMBOL(up_read); | ||
|
||
/* | ||
* release a write lock | ||
*/ | ||
void up_write(struct rw_semaphore *sem) | ||
{ | ||
rwsem_release(&sem->dep_map, 1, _RET_IP_); | ||
|
||
__up_write(sem); | ||
} | ||
|
||
EXPORT_SYMBOL(up_write); | ||
|
||
/* | ||
* downgrade write lock to read lock | ||
*/ | ||
void downgrade_write(struct rw_semaphore *sem) | ||
{ | ||
/* | ||
* lockdep: a downgraded write will live on as a write | ||
* dependency. | ||
*/ | ||
__downgrade_write(sem); | ||
} | ||
|
||
EXPORT_SYMBOL(downgrade_write); |
Oops, something went wrong.