CK_PR_FENCE_ATOMIC(3)
π CK_PR_FENCE_ATOMIC(3) π
okay bestie, pull up a chair, because we're talking about ck_pr_fence_atomic β it's a page from the Concurrency Kit manual (that's section 3, the library one, iykyk) β¨
π LIBRARY
Concurrency Kit β link it like libck, so -lck π
β¨ SYNOPSIS β¨
#include <ck_pr.h>
void
ck_pr_fence_atomic(void);
void
ck_pr_fence_strict_atomic(void);
π¦ DESCRIPTION π¦
so. ck_pr_fence_atomic() is the girl who keeps the timeline straight π
She enforces the ordering of any atomic read-modify-write operations relative to whenever you invoke her. Like, if you call her, she makes sure everything lines up in the right order around that call. periodt.
This function always serves as an implicit compiler barrier. Always. No cap. π«Ά
Now here's where the architecture lore kicks in:
- On architectures implementing
CK_MD_TSO, this operation only serves as a compiler barrier β and like, no fences are emitted at all. she's just vibing. π - On architectures implementing
CK_MD_PSOandCK_MD_RMO, a store fence is emitted. okay so she does put in work there. π₯
But if you want to force the unconditional emission of a fence β no matter what, no excuses, no architecture opinions β use ck_pr_fence_strict_atomic(). she does not skip leg day. π
lowkey important: the strict version is the one you reach for when you need that fence emitted, period, instead of "well, depends on the memory model bestie." π
πΈ EXAMPLE πΈ
here's the whole vibe, verbatim, don't @ me:
#include <ck_pr.h>
static int a = 0;
static int b = 0;
static int c = 0;
void
function(void)
{
ck_pr_fas_int(&a, 1);
/*
* Guarantee that the update to a is completed
* with respect to the updates of b and c.
*/
ck_pr_fence_atomic();
ck_pr_fas_int(&b, 2);
ck_pr_fas_int(&c, 2);
return;
}
likeβ¦ the ck_pr_fence_atomic() in the middle is literally the main character here π she's guaranteeing that the update to a is completed with respect to the updates of b and c. iconic behavior, honestly.
π RETURN VALUES π
This function has no return value. she gives nothing back and that's the point. π (not in a bad way!! in a "void function" way π«Ά)
π SEE ALSO π
the whole friend group, go say hi:
ck_pr_stall(3)ck_pr_fence_atomic_store(3)ck_pr_fence_atomic_load(3)ck_pr_fence_store(3)ck_pr_fence_load(3)ck_pr_fence_load_atomic(3)ck_pr_fence_load_store(3)ck_pr_fence_load_depends(3)ck_pr_fence_memory(3)ck_pr_barrier(3)ck_pr_fas(3)ck_pr_load(3)ck_pr_store(3)ck_pr_faa(3)ck_pr_inc(3)ck_pr_dec(3)ck_pr_neg(3)ck_pr_not(3)ck_pr_add(3)ck_pr_sub(3)ck_pr_and(3)ck_pr_or(3)ck_pr_xor(3)ck_pr_cas(3)ck_pr_btc(3)ck_pr_bts(3)ck_pr_btr(3)
Additional information available at http://concurrencykit.org/ π
and that's the whole page, bestie!! this one was dated May 16, 2013, from the Concurrency Kit crew β mwah, thank you for the fences, we're obsessed πβ¨π§ββοΈ
π¦ where this page comes from
- alpine 3.24: ck-doc 0.7.2-r1 Β· BSD-2-Clause AND Apache-2.0
- debian bookworm: libck-dev 0.7.1-10 Β· BSD-2-Clause
- debian trixie: libck-dev 0.7.2-6 Β· BSD-2-Clause
- epel 10: ck-devel 0.7.2-1.el10_1 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- epel 9: ck-devel 0.7.0-10.el9 Β· BSD
- fedora 43: ck-devel 0.7.2-2.fc43 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 43: ck-devel 0.7.2-2.fc43 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 44: ck-devel 0.7.2-4.fc44 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- fedora 44: ck-devel 0.7.2-4.fc44 Β· BSD-2-clause AND Apache-2.0 AND BSD-3-clause
- nixos 26.05: ck 0.7.2
- nixpkgs unstable: ck 0.7.2
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- opensuse-leap 16.0: ck-devel 0.7.2-bp160.1.9 Β· Apache-2.0 AND BSD-2-Clause
- ubuntu jammy: libck-dev 0.7.1-6ubuntu2 Β· BSD-2-Clause
- ubuntu noble: libck-dev 0.7.1-13build1 Β· BSD-2-Clause
- ubuntu questing: libck-dev 0.7.2-5ubuntu1
- ubuntu resolute: libck-dev 0.7.2-5ubuntu2 Β· BSD-2-Clause
- ubuntu stonking: libck-dev 0.7.2-11 Β· BSD-2-Clause
- Copyright 2013 Samy Al Bahra
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms