📨 chic 0.0.0
Realtime-safe channels in C
Loading...
Searching...
No Matches
wait.h File Reference

Target-dependent wait hints. More...

#include <stddef.h>
#include <stdatomic.h>

Go to the source code of this file.

Functions

void chic_yield (void)
 Yields the current thread execution, allowing other threads to run.
static void busy_wait_hint (void)
 Platform-dependent hint to the processor that it is in a busy-wait loop.
static void busy_wait_on (const void *addr)

Variables

atomic_size_t chic_catastrophe_threshold
 Maximum number of permitted busy-wait loop iterations per send/recieve operation before the thread is yielded. Set to 1024 by default, but this can be overridden at runtime.

Detailed Description

Target-dependent wait hints.

Author
Fawn rubie.nosp@m.fawn.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
Date
2026

Function Documentation

◆ busy_wait_hint()

void busy_wait_hint ( void )
inlinestatic

Platform-dependent hint to the processor that it is in a busy-wait loop.

This helps optimize spinlocks by slowing down the processor a bit, which helps reduce contention on atomics.

See also
x86-64 pause
ARM64 isb (and why it is used instead of yield)
ARM32 yield
RISC-V pause

◆ busy_wait_on()

void busy_wait_on ( const void * addr)
inlinestatic
See also
ref busy_wait_hint
RISC-V wrs

Variable Documentation

◆ chic_catastrophe_threshold

atomic_size_t chic_catastrophe_threshold
extern

Maximum number of permitted busy-wait loop iterations per send/recieve operation before the thread is yielded. Set to 1024 by default, but this can be overridden at runtime.