|
PatchworkOS
|
Read-Write Ticket Lock. More...
Data Structures | |
| struct | rwlock_t |
| Read-Write Ticket Lock structure. More... | |
Macros | |
| #define | RWLOCK_DEADLOCK_TIMEOUT (CLOCKS_PER_SEC * 10) |
| Maximum time before we consider a deadlock to have occurred. | |
| #define | RWLOCK_READ_SCOPE(lock) |
| Acquires a rwlock for reading for the reminder of the current scope. | |
| #define | RWLOCK_WRITE_SCOPE(lock) |
| Acquires a rwlock for writing for the reminder of the current scope. | |
| #define | RWLOCK_CREATE |
| Create a rwlock initializer. | |
Functions | |
| void | rwlock_init (rwlock_t *lock) |
| Initializes a rwlock. | |
| void | rwlock_read_acquire (rwlock_t *lock) |
| Acquires a rwlock for reading, blocking until it is available. | |
| void | rwlock_read_release (rwlock_t *lock) |
| Releases a rwlock from reading. | |
| void | rwlock_write_acquire (rwlock_t *lock) |
| Acquires a rwlock for writing, blocking until it is available. | |
| void | rwlock_write_release (rwlock_t *lock) |
| Releases a rwlock from writing. | |
| static void | rwlock_read_cleanup (rwlock_t **lock) |
| static void | rwlock_write_cleanup (rwlock_t **lock) |
Read-Write Ticket Lock.
| #define RWLOCK_CREATE |
Create a rwlock initializer.
| #define RWLOCK_DEADLOCK_TIMEOUT (CLOCKS_PER_SEC * 10) |
| #define RWLOCK_READ_SCOPE | ( | lock | ) |
Acquires a rwlock for reading for the reminder of the current scope.
| lock | Pointer to the rwlock to acquire. |
| #define RWLOCK_WRITE_SCOPE | ( | lock | ) |
Acquires a rwlock for writing for the reminder of the current scope.
| lock | Pointer to the rwlock to acquire. |
| void rwlock_init | ( | rwlock_t * | lock | ) |
Initializes a rwlock.
| lock | Pointer to the rwlock to initialize. |
Definition at line 8 of file rwlock.c.
References rwlock_t::activeReaders, rwlock_t::activeWriter, atomic_init, lock, rwlock_t::readServe, rwlock_t::readTicket, rwlock_t::writeServe, and rwlock_t::writeTicket.
Referenced by key_init(), local_listen_dir_init(), namespace_init(), process_init(), vfs_list_init(), and vfs_map_init().
| void rwlock_read_acquire | ( | rwlock_t * | lock | ) |
Acquires a rwlock for reading, blocking until it is available.
| lock | Pointer to the rwlock to acquire. |
Definition at line 18 of file rwlock.c.
References rwlock_t::activeReaders, atomic_fetch_add, atomic_load, atomic_thread_fence, interrupt_disable(), lock, memory_order_seq_cst, NULL, panic(), rwlock_t::readServe, rwlock_t::readTicket, RWLOCK_DEADLOCK_TIMEOUT, start(), timer_uptime(), rwlock_t::writeServe, and rwlock_t::writeTicket.
Referenced by namespace_get_root_path().
|
inlinestatic |
Definition at line 103 of file rwlock.h.
References lock, and rwlock_read_release().
| void rwlock_read_release | ( | rwlock_t * | lock | ) |
Releases a rwlock from reading.
| lock | Pointer to the rwlock to release. |
Definition at line 57 of file rwlock.c.
References rwlock_t::activeReaders, atomic_fetch_add, atomic_fetch_sub, interrupt_enable(), lock, and rwlock_t::readServe.
Referenced by namespace_get_root_path(), and rwlock_read_cleanup().
| void rwlock_write_acquire | ( | rwlock_t * | lock | ) |
Acquires a rwlock for writing, blocking until it is available.
| lock | Pointer to the rwlock to acquire. |
Definition at line 65 of file rwlock.c.
References rwlock_t::activeReaders, rwlock_t::activeWriter, atomic_compare_exchange_weak, atomic_fetch_add, atomic_load, atomic_thread_fence, interrupt_disable(), lock, memory_order_seq_cst, NULL, panic(), RWLOCK_DEADLOCK_TIMEOUT, start(), timer_uptime(), rwlock_t::writeServe, and rwlock_t::writeTicket.
Referenced by local_listen_free(), namespace_bind(), namespace_deinit(), namespace_mount(), and process_free().
|
inlinestatic |
Definition at line 108 of file rwlock.h.
References lock, and rwlock_write_release().
| void rwlock_write_release | ( | rwlock_t * | lock | ) |
Releases a rwlock from writing.
| lock | Pointer to the rwlock to release. |
Definition at line 116 of file rwlock.c.
References rwlock_t::activeWriter, atomic_fetch_add, atomic_store, interrupt_enable(), lock, and rwlock_t::writeServe.
Referenced by local_listen_free(), namespace_bind(), namespace_deinit(), namespace_mount(), process_free(), and rwlock_write_cleanup().