CK_PR_FENCE_LOAD_STORE(3)
β¨ ck_pr_fence_load_store β bestie's guide to making loads wait their turn before stores π
okay so this is the manual for ck_pr_fence_load_store(3) and honestly? she's a baddie. let's get into it π«Ά
π LIBRARY
Concurrency Kit β aka libck, and you link her with -lck. that's it that's the vibe. π₯
πΈ SYNOPSIS
#include <ck_pr.h>
void
ck_pr_fence_load_store(void);
void
ck_pr_fence_strict_load_store(void);
two whole functions. twins. sisters. one is chill, one is strict. pick your fighter π
β¨ DESCRIPTION
so what does this fence actually do, bestie? it enforces the ordering of any memory load and ck_pr_load(3) operations with respect to store operations, relative to the moment you invoke the function. it's giving "no you don't get to reorder me, i'm the main character" π
and there's more: any store operations that were committed on remote processors and received by the calling processor before the invocation of ck_pr_fence_load_store() are also made visible only after a call to the ck_pr_fence_load family of functions. so like, the visibility timing is not a free-for-all, it's scheduled, periodt.
this function always serves as an implicit compiler barrier β always, no exceptions, she's reliable like that.
now the architecture tea β: on architectures with CK_MD_TSO or CK_MD_PSO specified (that's total store ordering and partial store ordering respectively, iykyk), this operation only serves as a compiler barrier and no fence instructions will be emitted. so like, no hardware fence, just the compiler behaving.
but if you want to force the unconditional emission of a load fence? use ck_pr_fence_strict_load_store(). that's the strict twin's whole job. she doesn't do vibes, she does instructions. π
and architectures implementing CK_MD_RMO? they always emit a fence. no discussion, no debate. π
π EXAMPLE
okay bestie here's what it looks like in the wild:
#include <ck_pr.h>
static unsigned int a;
static unsigned int b;
void
function(void)
{
unsigned int snapshot_a;
snapshot_a = ck_pr_load_uint(&a);
/*
* Guarantee that the load from "a" completes
* before the store to "b".
*/
ck_pr_fence_load_store();
ck_pr_store_uint(&b, 1);
return;
}
see how she loads a, drops the fence, then stores b? that's the whole point. the comment literally spells it out: guarantee that the load from "a" completes before the store to "b". iconic behavior, no notes π
π¦ RETURN VALUES
this function has no return value. she gives you nothing back. she just does her job and leaves. queen shit. π
π SEE ALSO
the whole friend group, go say hi to all of them:
ck_pr_stall(3)ck_pr_fence_atomic(3)ck_pr_fence_atomic_store(3)ck_pr_fence_atomic_load(3)ck_pr_fence_load_depends(3)ck_pr_fence_load_atomic(3)ck_pr_fence_store(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)
and if you want even more, additional information is available at http://concurrencykit.org/ πβ¨
lowkey sign-off: this page is dated May 18, 2013 and it lives in the CK_PR_FENCE_LOAD_STORE(3) section of your friendly neighborhood manual. go forth and fence responsibly, bestie ππΈ
π¦ 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