Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GStreamer
gstreamer
Commits
5aeb28aa
Commit
5aeb28aa
authored
Mar 19, 2009
by
Wim Taymans
Browse files
docs: interesting idea for fast rw locks
--
parent
4eacc035
Changes
1
Show whitespace changes
Inline
Side-by-side
docs/random/wtay/rwlocks
0 → 100644
View file @
5aeb28aa
***********************************************
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);
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment