Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
emper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lehrstuhl für Informatik 4 (Systemsoftware)
manycore
emper
Commits
9a255dd5
Commit
9a255dd5
authored
3 years ago
by
Florian Schmaus
Browse files
Options
Downloads
Patches
Plain Diff
[Fiber] Improve memory order of reference counter
parent
9bb8f489
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!195
[LAWS/Fiber] Introduce the concept of Multi-Fiber
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
emper/Fiber.hpp
+11
-3
11 additions, 3 deletions
emper/Fiber.hpp
with
11 additions
and
3 deletions
emper/Fiber.hpp
+
11
−
3
View file @
9a255dd5
...
...
@@ -91,15 +91,23 @@ class ALIGN_TO_CACHE_LINE Fiber : public Logger<LogSubsystem::F> {
return
runnable
.
exchange
(
false
);
}
inline
auto
doAtomicIncrRefCount
()
->
unsigned
int
{
inline
void
doAtomicIncrRefCount
()
{
assert
(
referenceCounter
<
UINT_MAX
);
isMulti
=
true
;
return
++
referenceCounter
;
// Note: Although the first impulse is to prevent the re-ordering
// of the isMulti store after the reference counter modification,
// this *should* not be necessary. The sychronization point where
// this ordering is guranteed is, when the fiber is put in a
// concurrent queue. There the queue must gurantee that all
// previous stores are visible at the time the fiber appears in
// the queue to other threads.
referenceCounter
.
fetch_add
(
1
,
std
::
memory_order_relaxed
);
}
inline
auto
doAtomicDecrRefCount
()
->
unsigned
int
{
assert
(
referenceCounter
>
0
);
return
--
referenceCounter
;
auto
previous
=
referenceCounter
.
fetch_sub
(
1
,
std
::
memory_order_acq_rel
);
return
previous
-
1
;
}
template
<
LogSubsystem
>
...
...
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