Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
8a655c60
Commit
8a655c60
authored
Nov 04, 2008
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comment
include/waiting_threads.h: comment with a deadlock example
parent
f91219ed
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletion
+25
-1
include/waiting_threads.h
include/waiting_threads.h
+25
-1
No files found.
include/waiting_threads.h
View file @
8a655c60
...
...
@@ -80,7 +80,31 @@ typedef struct st_wt_resource {
#ifdef WT_RWLOCKS_USE_MUTEXES
/*
we need a special rwlock-like 'lock' to allow readers bypass
waiting writers, otherwise readers can deadlock.
waiting writers, otherwise readers can deadlock. For example:
A waits on resource x, owned by B, B waits on resource y, owned
by A, we have a cycle (A->x->B->y->A)
Both A and B start deadlock detection:
A locks x B locks y
A goes deeper B goes deeper
A locks y B locks x
with mutexes it would deadlock. With rwlocks it won't, as long
as both A and B are taking read locks (and they do).
But other threads may take write locks. Assume there's
C who wants to start waiting on x, and D who wants to start
waiting on y.
A read-locks x B read-locks y
A goes deeper B goes deeper
=> C write-locks x (to add a new edge) D write-locks y
.. C is blocked D is blocked
A read-locks y B read-locks x
Now, if a read lock can bypass a pending wrote lock request, we're fine.
If it can not, we have a deadlock.
writer starvation is technically possible, but unlikely, because
the contention is expected to be low.
*/
...
...
Write
Preview
Markdown
is supported
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