27#define RWLOCK_DEADLOCK_ITERATIONS 10000000
34#define RWLOCK_READ_SCOPE(lock) \
35 __attribute__((cleanup(rwlock_read_cleanup))) rwlock_t* CONCAT(rl, __COUNTER__) = (lock); \
36 rwlock_read_acquire((lock))
43#define RWLOCK_WRITE_SCOPE(lock) \
44 __attribute__((cleanup(rwlock_write_cleanup))) rwlock_t* CONCAT(wl, __COUNTER__) = (lock); \
45 rwlock_write_acquire((lock))
52#define RWLOCK_CREATE() \
55 .readTicket = ATOMIC_VAR_INIT(0), .readServe = ATOMIC_VAR_INIT(0), .writeTicket = ATOMIC_VAR_INIT(0), \
56 .writeServe = ATOMIC_VAR_INIT(0), .activeReaders = ATOMIC_VAR_INIT(0) \
109 panic(
NULL,
"Deadlock in rwlock_read_acquire detected");
132 panic(
NULL,
"Deadlock in rwlock_read_acquire detected");
173 panic(
NULL,
"Deadlock in rwlock_write_acquire detected");
184 panic(
NULL,
"Deadlock in rwlock_write_acquire detected");
static void cli_pop(void)
Decrements the CLI depth, re-enabling interrupts if depth reaches zero and interrupts were enabled pr...
static void cli_push(void)
Increments the CLI depth, disabling interrupts if depth was zero.
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
static void rwlock_write_release(rwlock_t *lock)
Releases a rwlock from writing.
static void rwlock_init(rwlock_t *lock)
Initializes a rwlock.
static void rwlock_read_release(rwlock_t *lock)
Releases a rwlock from reading.
static void rwlock_write_cleanup(rwlock_t **lock)
static void rwlock_write_acquire(rwlock_t *lock)
Acquires a rwlock for writing, blocking until it is available.
#define RWLOCK_DEADLOCK_ITERATIONS
Number of iterations before we consider a deadlock to have occurred in a rwlock operation....
static void rwlock_read_cleanup(rwlock_t **lock)
static void rwlock_read_acquire(rwlock_t *lock)
Acquires a rwlock for reading, blocking until it is available.
#define ASM(...)
Inline assembly macro.
#define NULL
Pointer error value.
#define atomic_fetch_add_explicit(object, operand, order)
#define atomic_load_explicit(object, order)
#define atomic_init(obj, value)
#define atomic_fetch_sub_explicit(object, operand, order)
Read-Write Ticket Lock structure.
atomic_uint16_t writeTicket
atomic_uint16_t activeReaders
atomic_uint16_t readTicket
atomic_uint16_t writeServe
atomic_uint16_t readServe
Thread of execution structure.