interruptible rwsems
Subsystems (2)
PATCH 1/1 interruptible rwsems
Hi Linus,
Here's a patch to add interruptible down functions for rwsems (developed by Murali N Vilayannur with help from myself).
David
include/linux/rwsem.h +32 -0
@@ -2,6 +2,8 @@* * Written by David Howells ([email protected]). * Derived from asm-i386/semaphore.h +* - Trylock stuff by Brian J. Watson <[email protected]> +* - Interruptible stuff by Murali N Vilayannur <[email protected]> */ #ifndef _LINUX_RWSEM_H
@@ -59,6 +61,21 @@ }/* +* lock for reading which can be interrupted. +* Returns 0 if we obtained the lock and -EINTR +* if we were interrupted and we did not obtain the lock. +*/ +static inline int down_read_interruptible (struct rw_semaphore *sem) +{ +int ret; +might_sleep (); +rwsemtrace (sem,"Entering down_read_interruptible" ); + ret =__down_read_interruptible (sem); +rwsemtrace (sem,"Leaving down_read_interruptible" ); +return ret; +} + +/* * lock for writing */ static inline void down_write (struct rw_semaphore *sem)
@@ -82,6 +99,21 @@ }/* +* lock for writing which can be interrupted. +* Returns 0 if we obtained the lock and -EINTR +* if we were interrupted and we did not obtain the lock. +*/ +static inline int down_write_interruptible (struct rw_semaphore *sem) +{ +int ret; +might_sleep (); +rwsemtrace (sem,"Entering down_write_interruptible" ); + ret =__down_write_interruptible (sem); +rwsemtrace (sem,"Leaving down_write_interruptible" ); +return ret; +} + +/* * release a read lock */ static inline void up_read (struct rw_semaphore *sem)
include/linux/rwsem-spinlock.h +4 -0
@@ -3,6 +3,8 @@* Copyright (c) 2001 David Howells ([email protected]). * - Derived partially from ideas by Andrea Arcangeli <[email protected]> * - Derived also from comments by Linus +* - Trylock stuff by Brian J. Watson <[email protected]> +* - Interruptible stuff by Murali N Vilayannur <[email protected]> */ #ifndef _LINUX_RWSEM_SPINLOCK_H
@@ -55,8 +57,10 @@extern void FASTCALL (init_rwsem (struct rw_semaphore *sem));extern void FASTCALL (__down_read (struct rw_semaphore *sem));extern int FASTCALL (__down_read_trylock (struct rw_semaphore *sem)); +extern int FASTCALL (__down_read_interruptible (struct rw_semaphore *sem));extern void FASTCALL (__down_write (struct rw_semaphore *sem));extern int FASTCALL (__down_write_trylock (struct rw_semaphore *sem)); +extern int FASTCALL (__down_write_interruptible (struct rw_semaphore *sem));extern void FASTCALL (__up_read (struct rw_semaphore *sem));extern void FASTCALL (__up_write (struct rw_semaphore *sem));extern void FASTCALL (__downgrade_write (struct rw_semaphore *sem));
include/asm-i386/rwsem.h +68 -0
92 lines not on this page · raw message
lib/rwsem.c +96 -0
127 lines not on this page · raw message
lib/rwsem-spinlock.c +127 -0
153 lines not on this page · raw message
Quoted 2 lines · David Howells
Here's a patch to add interruptible down functions for rwsems (developed by Murali N Vilayannur with help from myself).
Do we actually have a potential use for this, or is it just cool infrastructure?
Regards,
Paul.
Quoted 6 lines
Quoted 3 lines
Here's a patch to add interruptible down functions for rwsems (developed by Murali N Vilayannur with help from myself).
Do we actually have a potential use for this, or is it just cool infrastructure?
Murali Vilayannur does.
David