kernel: Add read write spinlock implementation
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user