Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Verlässliche Systemsoftware
projects
osv
Commits
714bdb43
Commit
714bdb43
authored
11 years ago
by
Avi Kivity
Browse files
Options
Downloads
Patches
Plain Diff
rwlock: switch to new with_lock()
parent
ebfb17f7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/rwlock.cc
+8
-9
8 additions, 9 deletions
core/rwlock.cc
with
8 additions
and
9 deletions
core/rwlock.cc
+
8
−
9
View file @
714bdb43
...
...
@@ -41,7 +41,7 @@ void rwlock::runlock()
{
bool
need_wake
=
false
;
with_lock
(
_mtx
,
[
&
]
{
WITH_LOCK
(
_mtx
)
{
assert
(
_wowner
==
nullptr
);
assert
(
_readers
>
0
);
...
...
@@ -50,7 +50,7 @@ void rwlock::runlock()
if
((
--
_readers
==
0
)
&&
(
_write_waiters
))
{
need_wake
=
true
;
}
}
);
}
// wake() only after releasing the mutex
if
(
need_wake
)
{
...
...
@@ -104,16 +104,15 @@ bool rwlock::try_wlock()
void
rwlock
::
wunlock
()
{
with_lock
(
_mtx
,
[
&
]
{
WITH_LOCK
(
_mtx
)
{
assert
(
_wowner
==
sched
::
thread
::
current
());
if
(
_wrecurse
>
0
)
{
_wrecurse
--
;
return
;
}
else
{
_wowner
=
nullptr
;
}
_wowner
=
nullptr
;
});
}
// wake() only after releasing the mutex
if
(
_write_waiters
)
{
...
...
@@ -125,14 +124,14 @@ void rwlock::wunlock()
void
rwlock
::
downgrade
()
{
with_lock
(
_mtx
,
[
this
]
{
WITH_LOCK
(
_mtx
)
{
assert
(
_wowner
==
sched
::
thread
::
current
());
// I'm aware this implementation is ugly but it does the trick for the
// time being.
while
(
_wrecurse
)
this
->
wunlock
();
this
->
wunlock
();
}
);
}
// FIXME: Writers that already wait get precedence, so this function can
// block, there's only one user in sys/netinet/if_ether.c
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment