Skip to content

Commit

Permalink
dump
Browse files Browse the repository at this point in the history
Signed-off-by: Haile Lagi <[email protected]>
  • Loading branch information
hailelagi committed Dec 4, 2024
1 parent 4eaeb8f commit c2c4f3b
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions content/notes/atomics.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
---
title: "Atomics"
date: 2024-11-26T12:57:51+01:00
draft: true
draft: false
---

{{% callout %}}
This initial draft was to make some notes while reading marabos' atomics and locks,
and somehow transmogrify key concepts, distilling yet and perhaps wrapping it into a case study of
some sort, perhaps `WTF::parking_lot` or my own lock-free linked-list, sadly, although it does not meet any standards of quality or
comprehension, here it is, anyway, otherwise it may never escape my drafts.
{{% /callout %}}


Atomics, typically a compiler intrinsic, platform/hardware dependent(x86, risc-v, arm etc), OS dependent.
typically at least a pointer size -- in rust a [`usize`](https://doc.rust-lang.org/std/primitive.usize.html)

## Usecases/Patterns
- stop flag/locking primitive/aka naive mutex + busy wait
- thread progress reporting
- synchronization/barrier/fence etc
- lazy initialization

Typically a compiler intrinsic, platform/hardware dependent(x86, risc-v, arm etc), OS dependent.
Typically at least a pointer size -- in rust a [`usize`](https://doc.rust-lang.org/std/primitive.usize.html)

## Orderings
- Relaxed: total modification order
- Release & Acquire: happens-before btw thread A & B
- AcqRel, SeqCst:
- *Consume

> A happens-before relationship is formed when an acquire-load operation observes the result of a release-store operation. In this case, the store and everything before it, happened before the load and everything after it.
go mem: https://research.swtch.com/gomm
super helpful summary: https://gist.github.com/kprotty/bb26b963441baf2ab3486a07fbf4762e
overview: https://doc.rust-lang.org/nightly/nomicon/atomics.html
in full: https://en.cppreference.com/w/cpp/atomic/memory_order
- go mem: https://research.swtch.com/gomm
- overview: https://doc.rust-lang.org/nightly/nomicon/atomics.html
- super helpful summary(formalism): https://gist.github.com/kprotty/bb26b963441baf2ab3486a07fbf4762e
- c++ mem: https://en.cppreference.com/w/cpp/atomic/memory_order

- AcqRel, SeqCst:
- *Consume

## Load and Store

Expand Down

0 comments on commit c2c4f3b

Please sign in to comment.