Commit 5aeb28aa authored by Wim Taymans's avatar Wim Taymans
Browse files

docs: interesting idea for fast rw locks

--
parent 4eacc035
***********************************************
typedef struct {
int pre_count;
int post_count;
Mutex *lock;
} RWLock;
reader:
retry:
post = atomic_get (lock->post_count);
... do read ...
if (atomic_get (lock->pre_count) != post) {
/* wait for writer to finish then retry */
lock (lock->mutex);
unlock (lock->mutex);
goto retry;
}
writer:
lock (lock->mutex);
atomic_inc (lock->pre_count);
... update ...
atomic_inc (lock->post_count);
unlock (lock->mutex);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment