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

Functions for pinning & unpinning memory regions. More...

#include <stddef.h>
#include <stdbool.h>

Go to the source code of this file.

Functions

void * chic_prefault (void *addr, size_t size)
 Writes zeroes to several locations in a memory range to trigger page faults ahead of time.

Detailed Description

Functions for pinning & unpinning memory regions.

Author
Fawn rubie.nosp@m.fawn.nosp@m.@prot.nosp@m.on.m.nosp@m.e
Date
2026

Function Documentation

◆ chic_prefault()

void * chic_prefault ( void * addr,
size_t size )

Writes zeroes to several locations in a memory range to trigger page faults ahead of time.

This is to prevent those page faults from happening later in a real-time context. Rather than zeroing the entire buffer, this function tries to only write once per memory page in the range addr to addr + size.

For best results, this memory range should be immediately pinned using chic_pin.

Parameters
addrThe beginning of the memory range to prefault
sizeThe length of the memory range to prefault
Returns
addr