kernel: Add read write spinlock implementation

This commit is contained in:
Pawel Dziepak
2013-11-07 04:20:32 +01:00
parent 20ded5c2eb
commit defee266db
4 changed files with 258 additions and 0 deletions
+16
View File
@@ -40,6 +40,15 @@ typedef ulong cpu_status;
# define B_SPINLOCK_IS_LOCKED(lock) (*(lock) > 0)
#endif
typedef struct {
int32 lock;
} rw_spinlock;
#define B_RW_SPINLOCK_INITIALIZER { 0 }
#define B_INITIALIZE_RW_SPINLOCK(rw_spinlock) do { \
(rw_spinlock)->lock = 0; \
} while (false)
typedef struct {
spinlock lock;
uint32 count;
@@ -137,6 +146,13 @@ extern void restore_interrupts(cpu_status status);
extern void acquire_spinlock(spinlock *lock);
extern void release_spinlock(spinlock *lock);
extern bool try_acquire_write_spinlock(rw_spinlock* lock);
extern void acquire_write_spinlock(rw_spinlock* lock);
extern void release_write_spinlock(rw_spinlock* lock);
extern bool try_acquire_read_spinlock(rw_spinlock* lock);
extern void acquire_read_spinlock(rw_spinlock* lock);
extern void release_read_spinlock(rw_spinlock* lock);
extern bool try_acquire_write_seqlock(seqlock* lock);
extern void acquire_write_seqlock(seqlock* lock);
extern void release_write_seqlock(seqlock* lock);