MMgr v2.3.0
Zero-heap memory manager in C11. One borrowed buffer, carved by asserted offset.
Loading...
Searching...
No Matches
SeriesCellularum Struct Reference

One cellblock's state: its bytes, the two boundaries that grow toward each other, and the closed word a writer holds. Also the sink a refused store lands on, and the turnstiles every pass goes through. More...

#include <locus_carcerum.h>

Data Fields

uint8_t * base
size_t size
embed_atomic_usize bounds
embed_atomic_usize persistent_overrun
embed_atomic_usize temporary_overrun
embed_atomic_usize in_use
embed_atomic_usize persistent_in_use
embed_atomic_uptr movable
embed_atomic_word closed
embed_atomic_word epoch
embed_atomic_usize sink
EmbedTurnstiles turnstiles

Detailed Description

One cellblock's state: its bytes, the two boundaries that grow toward each other, and the closed word a writer holds. Also the sink a refused store lands on, and the turnstiles every pass goes through.

Note
Written by the declaration that emits the cellblock and by the entries that cellblock owns. The base is the cellblock's own storage, and nothing derives an address from a site and an index.
bounds is the two boundaries in one word, each a position in bytes from the base of its tier's frame. Its low half names the offset just past the last persistent cell, and its high half the offset of the lowest temporary cell. A take bumps its tier's half by one fetch-add on the word. The old value carries the other boundary as it was at that same instant: the room the take reads. A bump the gap cannot meet leaves the boundary where it moved it and adds its bytes to the tier's overrun, persistent_overrun or temporary_overrun. Every later bump of either tier fails, since the boundaries only move toward each other between writers and every bump reads them as one word.
The next writer takes the overrun back off the boundary before it reads the tier. Between a refusal and that writer the boundary is past the tier's cells by the overrun. The page docs/concepts/locus-carcerum-algorithm.md writes the algorithm out and theory/locus_carcerum checks it.
closed is the writer's word: bit 0 while a compaction, a growth or a move works alone, bit 1 while a context sleeps on the word. A pass that reads bit 0 set touches nothing and tries once more after a backoff step. The word sink is the one every store of a pass that touches nothing lands on.
Above its four flag bits, closed holds the bank count and the frame of each tier, the bank its position counts from. A pass reads them with its permit, and only a writer with every pass drained changes them. The member epoch is odd while a writer changes them, so a reader outside a pass reads a frame and a position as one.
turnstiles is the bank of lanes a pass badges in at, EmbedTurnstiles' way, which a writer drains after it sets the closed bit. Zero at rest, as the last member, which a declaration leaves to the zero fill of static storage.
The member in_use is this cellblock's total, counted where each owner's is. The member persistent_in_use is the part of it in the persistent tier, which a sort reads. The member movable is the option mmgr_movable_init assigns, and it reads zero without it.
Where MMGR_CARCER_REGIONS is above 0, the temporary tier is the regions, and the top in bounds stays at the regions' start. Each region's depth is the bytes its stack holds from its end down, on a lane of its own. A take bumps the depth of the region the thread's place selects by one fetch-add, and a bump the region cannot hold goes back by one fetch-sub before the take goes on to the writer's path.

Definition at line 579 of file locus_carcerum.h.

Field Documentation

◆ base

uint8_t* SeriesCellularum::base

First byte of the cellblock [BORROWS]; NULL over a hospes pool until placed.

Definition at line 581 of file locus_carcerum.h.

◆ size

size_t SeriesCellularum::size

Bytes in the cellblock; 0 over a hospes pool until placed.

Definition at line 582 of file locus_carcerum.h.

Referenced by mmgr_series_cellularum_idle().

◆ bounds

embed_atomic_usize SeriesCellularum::bounds

The persistent position in the low half, the temporary position in the high.

Definition at line 583 of file locus_carcerum.h.

◆ persistent_overrun

embed_atomic_usize SeriesCellularum::persistent_overrun

Bytes refused takes moved the persistent end by since the last writer.

Definition at line 585 of file locus_carcerum.h.

◆ temporary_overrun

embed_atomic_usize SeriesCellularum::temporary_overrun

Bytes refused takes moved the temporary top by since the last writer.

Definition at line 586 of file locus_carcerum.h.

◆ in_use

embed_atomic_usize SeriesCellularum::in_use

Payload bytes of the cells taken and not given back.

Definition at line 587 of file locus_carcerum.h.

◆ persistent_in_use

embed_atomic_usize SeriesCellularum::persistent_in_use

The part of in_use in the persistent tier.

Definition at line 588 of file locus_carcerum.h.

◆ movable

embed_atomic_uptr SeriesCellularum::movable

The movable option's state, as an integer, zero without it.

Definition at line 589 of file locus_carcerum.h.

◆ closed

embed_atomic_word SeriesCellularum::closed

The writer's bit, the sleeper flag, the trim bits and the frames.

Definition at line 590 of file locus_carcerum.h.

Referenced by mmgr_series_cellularum_banks().

◆ epoch

embed_atomic_word SeriesCellularum::epoch

Odd while a writer changes the frames.

Definition at line 591 of file locus_carcerum.h.

◆ sink

embed_atomic_usize SeriesCellularum::sink

Where a store that must not land lands.

Definition at line 592 of file locus_carcerum.h.

◆ turnstiles

EmbedTurnstiles SeriesCellularum::turnstiles

The lanes a pass badges in at.

Definition at line 597 of file locus_carcerum.h.


The documentation for this struct was generated from the following file: