MMgr v2.3.0
Zero-heap memory manager in C11. One borrowed buffer, carved by asserted offset.
Loading...
Searching...
No Matches
locus_carcerum — the region and its pools

Data Structures

struct  CellOwner
 Asserts MMGR_CARCER_ALIGN is a power of two. More...
struct  SeriesCellularum
 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...
struct  CarcerMovableInitCfg
 What a program gives a cellblock for the movable option, once, through its guard's movable_init. More...
struct  CarcerMovableCfg
 Arguments for the calls that reach a movable cell's bytes, each of which reads the members it names. More...
struct  MinimumSecurityGuard
 The minimum security guard over one cellblock: a released cell retains whatever is in it. More...
struct  MaxSecurityGuard
 The max security guard over one cellblock: every release zeroes the cell first. More...

Macros

#define MMGR_ENABLE_HW_MEM_CAPACITY_CB
 Set to 1 to track each tier's high-water mark.
#define MMGR_CARCER_OWNERS
 The max owners a program's owner table holds.
#define MMGR_MOVABLE_SETTLE_PERCENT
 The fragmentation at which a cellblock's mover sorts its movable cells, as a percentage of the bytes its persistent tier occupies.
#define MMGR_MOVABLE_READ_MS
 The milliseconds between the mover's readings of its cellblock.
#define MMGR_MOVABLE_QUIET_READINGS
 The readings in a row that must find the cellblock quiet before the mover sorts.
#define MMGR_MOVABLE_BACKOFF_MAX_MS
 The longest the mover waits between readings after a sort it backed off from.
#define MMGR_MOVABLE_IDLE_MAX_MS
 The longest the mover waits between readings of a settled cellblock that no pass touched since the last reading. Each such reading doubles the wait up to this. A pass or a rise brings the next reading back to MMGR_MOVABLE_READ_MS.
#define MMGR_CARCER_REGIONS
 The regions of the temporary tier: one stack of cells for each place the host gives a thread, modulo this count. 0 makes the temporary tier one stack that every thread shares.
#define MMGR_CARCER_REGION_BYTES
 Bytes of each region: its cells with their headers and owner words. A multiple of MMGR_CARCER_ALIGN.
#define MMGR_CARCER_LARGE_REGION_BYTES
 Bytes of the one large region, at the top of the cellblock, that every temporary take over a region's room goes to, from any thread. 0 refuses such a take.
#define MMGR_CARCER_LARGE_REGIONS
 1 where the cellblock has the large region, 0 where it has none.
#define MMGR_CARCER_REGION_COUNT
 The regions in all: one for each place, and the large one where the build declares it.
#define MMGR_CARCER_REGION_AREA
 Bytes the regions take off the top of every cellblock, 0 where the temporary tier is one stack.
#define MMGR_CARCER_ALIGN
 Alignment of every prisoner on the way out: one machine word, or the atomic size word's alignment where that is wider.
#define MMGR_OWNER_PLACE_BITS
 The owner word a cell carries behind its payload, one machine word positioned as fields, high to low. The fields are the owner's place in the table, the completion bit, the signal bits, and the nanosecond of the take. The clock is the library's, and the nanosecond rolls over its bits.
#define MMGR_OWNER_SIGNAL_BITS
#define MMGR_OWNER_TIME_BITS
#define MMGR_OWNER_TIME_MASK
#define MMGR_OWNER_SIGNAL_SHIFT
#define MMGR_OWNER_COMPLETE
#define MMGR_OWNER_PLACE_SHIFT
#define MMGR_OWNER_PLACE_MASK
#define MMGR_OWNER_PLACE(name_, text_)
 One owner's place in the table, counted from 0, as the enumeration MMGR_OWNERS positions names it.
#define MMGR_OWNER_RECORD(name_, text_)
 One owner's record as the table's initializer positions it: its name, its place from 1, nothing counted.
#define MMGR_OWNER_POINTER(name_, text_)
 One owner's identity defined: a const pointer to its record in the table, resolved by the linker.
#define MMGR_OWNER_EXTERN(name_, text_)
 One owner's identity declared, for the header the owner's module reads it through.
#define MMGR_OWNERS(list_)
 The program's owners declared as data: the table positioned, its count, and each owner's identity defined.
#define MMGR_CARCER_HALF_BITS
 The bits each boundary has in the word that carries both, half the atomic size word, and the mask of a half.
#define MMGR_CARCER_HALF_MASK
#define MMGR_CARCER_BYTES_MAX
 The reach of a position in a boundary half: half the half's values. The other half is the headroom the bumps a round refuses move the position into before the next writer settles it.
#define MMGR_CARCER_WANT_MAX
 The max payload one bump may ask. It is the headroom the bumps in flight on the turnstiles' lanes share. Each of them may move its boundary once past MMGR_CARCER_BYTES_MAX before the refusal stops the rest. A take past it goes to the writer's path at once.
#define MMGR_CARCER_BANK_SHIFT
 The bits of a bank's bytes: a bank is half the reach of a position. A test build can set fewer, so that a small pool spans many banks.
#define MMGR_CARCER_BANK_BYTES
 The bytes of one bank.
#define MMGR_CARCER_BANK_FIELD_BITS
 The bits of each field of the closed word above its four flag bits. The fields are the bank count, the frame of the persistent tier and the frame of the temporary tier, in that order.
#define MMGR_CARCER_BANK_FIELD_MASK
 The mask of one field, at bit 0.
#define MMGR_CARCER_BANK_COUNT_AT
 The bit of the closed word that each field starts at.
#define MMGR_CARCER_BANK_END_AT
#define MMGR_CARCER_BANK_TOP_AT
#define MMGR_CARCER_POOL_BYTES_MAX
 The max bytes one cellblock may hold: one less than the values of a field, times the bytes of a bank. So every frame and the bank count fit their fields.
#define MMGR_CARCER_BANK_OF(off_)
 The bank an offset is in.
#define MMGR_CARCER_BANK_COUNT(bytes_)
 The banks a cellblock of bytes_ bytes takes: its bytes rounded up to a whole bank.
#define MMGR_CARCER_FRAME_CAP(bytes_)
 The highest frame of a cellblock of bytes_ bytes: two banks below its bank count, or bank 0.
#define MMGR_CARCER_END_FRAME(end_, bytes_)
 The frame a writer gives a persistent end in a cellblock of bytes_ bytes: the end's bank, or the cap.
#define MMGR_CARCER_BANK_BELOW(top_)
 The bank below a top's own bank, or bank 0.
#define MMGR_CARCER_TOP_FRAME(top_, bytes_)
 The frame a writer gives a temporary top in a cellblock of bytes_ bytes: the bank below the top's own, or the cap.
#define MMGR_CARCER_CLOSED_AT_REST(bytes_)
 The closed word of a cellblock at rest over bytes_ bytes. It holds no flag, the bank count, the persistent frame at bank 0, and the temporary frame for the top at the regions' start.
#define MMGR_CARCER_BOUNDS_AT_REST(bytes_)
 The boundary word of a cellblock at rest over bytes_ bytes: the end at 0, the top's position in its frame.
#define MMGR_CARCER_STATE_HW
 The high-water members' first values, or nothing where the build tracks none.
#define MMGR_CARCER_STATE_REGIONS
 The regions' first depths, every one 0, or nothing where the temporary tier is one stack.
#define MMGR_CARCER_STATE_TURNSTILES
 The turnstiles' first values: each lane word, the top open lane and the queue length at 0.
#define MMGR_CARCER_STATE(base_, bytes_)
 A cellblock's state as it is over bytes_ bytes at base_ with no cell taken. Both tiers are empty, every mark is at zero, and the zero fill of the storage covers the turnstiles.
#define MMGR_CARCER_STATE_HOSPES
 The record of a cellblock over a hospes pool before the program places it: no base, no size, both boundaries at 0, so every take is refused until mmgr_series_cellularum_placed gives the storage.
#define MMGR_MOVABLE_HEAD_BYTES
 Bytes of the option's state ahead of its turnstiles, which locus_carcerum.c asserts it fits.
#define MMGR_MOVABLE_CLAIM_BITS
 The bits of one word of the option's claim bits: one an entry.
#define MMGR_MOVABLE_STORAGE_BYTES(cells_, width_, rows_)
 The storage the movable option takes for a table of cells_ entries and rows_ rows of touches.
#define MMGR_GUARD_MOVABLE_TAKE_MEMBERS
 The two movable members both guards hold ahead of their movable release.
#define MMGR_GUARD_MOVABLE_SPAN_MEMBERS
 The four movable members both guards hold after their movable release.
#define MMGR_GUARD_MEMBER_NAMES
 The thirteen member names of both guards, in their order, for EMBED_TABLE_LAYOUT.
#define MMGR_CARCER_MOVABLE_ENTRIES(prisonsite_, name_, wipe_to_zero_on_release_, series_cellularum_)
 The movable entries of one cellblock, bound to it through series_cellularum_.
#define MMGR_CARCER_BODY(prisonsite_, type_, name_, wipe_to_zero_on_release_, hospes_)
 Everything one cellblock is: its bytes, its state, and the entries bound to it.
#define MMGR_CARCER_STORAGE_0(prisonsite_, name_)
 A cellblock's record over the array its pool's declaration emitted: the asserts on the array's extent, and the record with the array as its base and the pool's count as its size.
#define MMGR_CARCER_STORAGE_1(prisonsite_, name_)
 A cellblock's record over a hospes pool: empty until the program places it.
#define MMGR_CARCER_MEM(prisonsite_, type_, name_, wipe_to_zero_on_release_, hospes_)
 One cellblock as a member of its site's type.
#define MMGR_CARCER_SEAT(prisonsite_, type_, name_, wipe_to_zero_on_release_, hospes_)
 One cellblock's entries, in the order its guard declares them.
#define MMGR_MINIMUM_SECURITY(name_)
 Declares a minimum security cellblock over a pool.
#define MMGR_MAXIMUM_SECURITY(name_)
 Declares a max security cellblock over a pool.
#define MMGR_MINIMUM_SECURITY_HOSPES(name_)
 Declares a minimum security cellblock over a hospes pool, one ParsMemoriaeHospes declared: the program gives the storage once, with mmgr_series_cellularum_placed, before the first take.
#define MMGR_MAXIMUM_SECURITY_HOSPES(name_)
 Declares a max security cellblock over a hospes pool, as MMGR_MINIMUM_SECURITY_HOSPES with the wipe on release.
#define MMGR_UNTUPLE(...)
 Strips a tuple's parentheses.
#define MMGR_CARCER_APPLY(what_, prisonsite_, tuple_)
 Applies one reader to one cellblock tuple, with the site spliced in ahead of it.
#define MMGR_CARCER_APPLY_(what_, prisonsite_, ...)
 Expands to what_(prisonsite_, VA_ARGS).
#define MMGR_CARCER_W1(what_, prisonsite_, SeriesCellularum1_)
 Applies the reader to a site's one cellblock tuple.
#define MMGR_CARCER_W2(what_, prisonsite_, SeriesCellularum1_, SeriesCellularum2_)
 Applies the reader to a site's two cellblock tuples.
#define MMGR_CARCER_W3(what_, prisonsite_, SeriesCellularum1_, SeriesCellularum2_, SeriesCellularum3_)
 Applies the reader to a site's three cellblock tuples.
#define MMGR_CARCER_W4(what_, prisonsite_, SeriesCellularum1_, SeriesCellularum2_, SeriesCellularum3_, SeriesCellularum4_)
 Applies the reader to a site's four cellblock tuples.
#define MMGR_CARCER_W5(what_, prisonsite_, SeriesCellularum1_, SeriesCellularum2_, SeriesCellularum3_, SeriesCellularum4_, SeriesCellularum5_)
 Applies the reader to a site's five cellblock tuples.
#define MMGR_CARCER_W6(what_, prisonsite_, SeriesCellularum1_, SeriesCellularum2_, SeriesCellularum3_, SeriesCellularum4_, SeriesCellularum5_, SeriesCellularum6_)
 Applies the reader to a site's six cellblock tuples.
#define MMGR_CARCER_W7(what_, prisonsite_, SeriesCellularum1_, SeriesCellularum2_, SeriesCellularum3_, SeriesCellularum4_, SeriesCellularum5_, SeriesCellularum6_, SeriesCellularum7_)
 Applies the reader to a site's seven cellblock tuples.
#define MMGR_CARCER_W8(what_, prisonsite_, SeriesCellularum1_, SeriesCellularum2_, SeriesCellularum3_, SeriesCellularum4_, SeriesCellularum5_, SeriesCellularum6_, SeriesCellularum7_, SeriesCellularum8_)
 Applies the reader to a site's eight cellblock tuples.
#define MMGR_CARCER_WALK(what_, prisonsite_, ...)
 Expands the walk that matches the cellblock count.
#define LocusCarcerum(prisonsite_, ...)
 Declares a prison site and the cellblocks built at it.

Typedefs

typedef struct CarcerMovableEntry CarcerMovableEntry
 The identity a movable cell's taker holds: a const pointer to the cell's entry in the cellblock's translation table.
typedef void(*) CarcerIdleEach(void *context, void *at, size_t bytes)
 A span of a cellblock's storage no cell holds, passed to the program: where it starts and its bytes.

Functions

EMBED_HOST_DEVICE uint64_t mmgr_carcer_hw_clock_ns (void)
 The library's clock in nanoseconds, which a cell's owner word carries the take on.
 EMBED_PASS_DECLARE (CellOwner, mmgr_owner_table, [])
 The program's owner table and the owners in it, which MMGR_OWNERS defines once.
 EMBED_PASS_DECLARE (const size_t, mmgr_owner_table_count,)
EMBED_HOST_DEVICE embed_bool mmgr_owner_listed (const CellOwner *owner)
 Whether an owner is one of the table's.
static EMBED_HOST_DEVICE size_t mmgr_owner_in_use (const CellOwner *owner)
 The payload bytes of the cells an owner has now.
static EMBED_HOST_DEVICE size_t mmgr_owner_hw (const CellOwner *owner)
 The max payload bytes an owner has had at once.
EMBED_HOST_DEVICE void mmgr_carcer_hw_misnamed (const CellOwner *named, const CellOwner *cell_owner, size_t bytes)
 Told of each give or growth that names an owner other than the one the cell counts to.
EMBED_HOST_DEVICE size_t mmgr_series_cellularum_persistent_end (const SeriesCellularum *series)
 Offset just past the last persistent cell.
EMBED_HOST_DEVICE size_t mmgr_series_cellularum_temporary_top (const SeriesCellularum *series)
 Offset of the lowest temporary cell.
static EMBED_HOST_DEVICE size_t mmgr_series_cellularum_banks (const SeriesCellularum *series)
 The banks a cellblock's bytes take, as its closed word holds the count.
static EMBED_HOST_DEVICE size_t mmgr_series_cellularum_region_depth (const SeriesCellularum *series, size_t region)
 The bytes one region's stack holds from its end down.
static EMBED_HOST_DEVICE embed_bool mmgr_series_cellularum_regions_idle (const SeriesCellularum *series)
 Whether every region is empty.
static EMBED_HOST_DEVICE embed_bool mmgr_series_cellularum_idle (const SeriesCellularum *series)
 Whether a cellblock has no cell out.
static EMBED_HOST_DEVICE size_t mmgr_series_cellularum_persistent_hw (const SeriesCellularum *series)
 The furthest point of a cellblock's persistent tier so far.
static EMBED_HOST_DEVICE size_t mmgr_series_cellularum_temporary_hw (const SeriesCellularum *series)
 The max bytes a cellblock's temporary tier took from the top at one time.
EMBED_HOST_DEVICE void * mmgr_persistent_buf_alloc (SeriesCellularum *series, size_t size, const CellOwner *owner)
 Takes size bytes from a cellblock's persistent tier.
EMBED_HOST_DEVICE void * mmgr_persistent_max_security_buf_alloc (SeriesCellularum *series, size_t size, const CellOwner *owner)
 Takes size bytes from a max security cellblock's persistent tier.
EMBED_HOST_DEVICE void mmgr_persistent_buf_release (SeriesCellularum *series, void *prisoner, const CellOwner *owner)
 Releases a prisoner and leaves the cell's bytes as they are.
EMBED_HOST_DEVICE void mmgr_persistent_max_security_buf_release (SeriesCellularum *series, void *prisoner, const CellOwner *owner)
 Zeroes a cell, then releases the prisoner.
EMBED_HOST_DEVICE void * mmgr_buf_grow (SeriesCellularum *series, void *prisoner, size_t size, const CellOwner *owner)
 Grows a cell to size payload bytes in place, where it is the newest cell of its tier.
EMBED_HOST_DEVICE void * mmgr_max_security_buf_grow (SeriesCellularum *series, void *prisoner, size_t size, const CellOwner *owner)
 Grows a cell in place as mmgr_buf_grow does, and zeroes the bytes the growth adds.
EMBED_HOST_DEVICE void * mmgr_temporary_buf_alloc (SeriesCellularum *series, size_t size, const CellOwner *owner)
 Takes size bytes from a cellblock's temporary tier.
EMBED_HOST_DEVICE void * mmgr_temporary_max_security_buf_alloc (SeriesCellularum *series, size_t size, const CellOwner *owner)
 Takes size bytes from a max security cellblock's temporary tier.
EMBED_HOST_DEVICE embed_bool mmgr_who_owns_buf (const SeriesCellularum *series, const void *at)
 Whether at lies inside the cellblock's bytes.
EMBED_HOST_DEVICE const CellOwner * mmgr_owner_of_buf (const SeriesCellularum *series, const void *prisoner)
 The owner a cell counts to, read off the word behind its payload.
EMBED_HOST_DEVICE size_t mmgr_buf_available (SeriesCellularum *series)
 The bytes between the two tiers.
EMBED_HOST_DEVICE void mmgr_zero_buf (void *prisoner, size_t size)
 Zeroes size bytes at prisoner and releases nothing.
EMBED_HOST_DEVICE size_t mmgr_align_up_buf (size_t size)
 Rounds size up to a whole machine word.
EMBED_HOST_DEVICE void mmgr_series_cellularum_emptied (SeriesCellularum *series)
 Puts a cellblock back to the state of its declaration. Both tiers are empty, the closed word and the turnstiles at rest, the option unassigned, and no byte of its storage touched.
EMBED_HOST_DEVICE embed_bool mmgr_series_cellularum_placed (SeriesCellularum *series, uint8_t *storage, size_t bytes)
 Places a cellblock declared over a hospes pool on the storage the program gives: its base and its size set, and the cellblock emptied over them.
EMBED_HOST_DEVICE void mmgr_series_cellularum_idle_each (SeriesCellularum *series, CarcerIdleEach each, void *context)
 Passes each span of the cellblock's storage that no cell holds to each, with the cellblock closed: the gap between the tiers, and the room of each region above its depth.
EMBED_HOST_DEVICE void mmgr_owner_bytes_taken (const CellOwner *owner, size_t bytes)
 Counts bytes that lie in no cellblock to an owner, as a ring's or a page's are.
EMBED_HOST_DEVICE void mmgr_owner_bytes_given (const CellOwner *owner, size_t bytes)
 Takes bytes mmgr_owner_bytes_taken counted off their owner.
EMBED_HOST_DEVICE size_t mmgr_series_cellularum_fragmentation (const SeriesCellularum *series)
 A cellblock's fragmentation: the bytes its persistent tier occupies and no cell's payload holds, as a percentage of the bytes it occupies.
EMBED_HOST_DEVICE embed_bool mmgr_movable_init (SeriesCellularum *series, const CarcerMovableInitCfg *args, embed_bool wipes)
 Assigns a cellblock's movable option: the translation table, its claim bits, the rows of touches and the mover's thread. A cellblock's guard calls this, as movable_init.
EMBED_HOST_DEVICE const CarcerMovableEntry * mmgr_movable_buf_alloc (SeriesCellularum *series, size_t size, const CellOwner *owner)
 Takes a persistent cell a move may move, and names it in the table.
EMBED_HOST_DEVICE embed_bool mmgr_movable_buf_release (SeriesCellularum *series, const CarcerMovableEntry *cell, const CellOwner *owner)
 Gives a movable cell back and frees its entry.
EMBED_HOST_DEVICE embed_bool mmgr_movable_buf_read (const SeriesCellularum *series, const CarcerMovableCfg *args)
 Copies args->bytes from args->offset of a movable cell to args->dst.
EMBED_HOST_DEVICE embed_bool mmgr_movable_buf_write (SeriesCellularum *series, const CarcerMovableCfg *args)
 Copies args->bytes from args->src to args->offset of a movable cell.
EMBED_HOST_DEVICE embed_iword mmgr_movable_buf_compare (const SeriesCellularum *series, const CarcerMovableCfg *args)
 Orders args->bytes of a movable cell against args->src, or against another cell where args->other_cell holds one.
EMBED_HOST_DEVICE size_t mmgr_movable_buf_measure (const SeriesCellularum *series, const CarcerMovableCfg *args)
 The bytes from args->offset of a movable cell to the next zero byte.
EMBED_HOST_DEVICE embed_bool mmgr_movable_buf_move (SeriesCellularum *series)
 Moves one movable cell into the first free cell below it, highest cell first.
EMBED_HOST_DEVICE void mmgr_movable_run (SeriesCellularum *series)
 The mover: what the thread the program gave runs, until its thread_wait answers EMBED_FALSE.
EMBED_HOST_DEVICE size_t mmgr_movable_queue_depth (const SeriesCellularum *series)
 The contexts queued at the cellblock's turnstiles now: those that found every open lane busy and wait for a lane.
EMBED_HOST_DEVICE embed_bool mmgr_movable_touches (const SeriesCellularum *series, size_t at, size_t *id, size_t *touches)
 One row of touches a lane, counted as passes go through it.

Detailed Description

Macro Definition Documentation

◆ MMGR_ENABLE_HW_MEM_CAPACITY_CB

#define MMGR_ENABLE_HW_MEM_CAPACITY_CB

Set to 1 to track each tier's high-water mark.

Note
Off by default because the two marks cost a size_t each in every SeriesCellularum, and a build that never reads them should not carry them.
Adds SeriesCellularum::persistent_hw and SeriesCellularum::temporary_hw, and the update that raises them in carcer_grow, which both tiers reach. One mark per tier: neither counts the other's bytes.
The #ifndef leaves a build's own definition in place, whether it arrives on the command line or from a header included ahead of this one.
Takes 0 or 1 alone. Both readers are #if, which would take any non-zero as set. The check below retains a mistyped value from a quiet growth of every SeriesCellularum.

Definition at line 53 of file locus_carcerum.h.

◆ MMGR_CARCER_OWNERS

#define MMGR_CARCER_OWNERS

The max owners a program's owner table holds.

Note
The table is the program's one list of owners, positioned by MMGR_OWNERS in the order of their declaration. An owner's place in it is its key. A declaration past this count fails the build.

Definition at line 66 of file locus_carcerum.h.

◆ MMGR_MOVABLE_SETTLE_PERCENT

#define MMGR_MOVABLE_SETTLE_PERCENT

The fragmentation at which a cellblock's mover sorts its movable cells, as a percentage of the bytes its persistent tier occupies.

Note
mmgr_series_cellularum_fragmentation reads what the build compares against this.

Definition at line 76 of file locus_carcerum.h.

◆ MMGR_MOVABLE_READ_MS

#define MMGR_MOVABLE_READ_MS

The milliseconds between the mover's readings of its cellblock.

Definition at line 84 of file locus_carcerum.h.

◆ MMGR_MOVABLE_QUIET_READINGS

#define MMGR_MOVABLE_QUIET_READINGS

The readings in a row that must find the cellblock quiet before the mover sorts.

Definition at line 89 of file locus_carcerum.h.

◆ MMGR_MOVABLE_BACKOFF_MAX_MS

#define MMGR_MOVABLE_BACKOFF_MAX_MS

The longest the mover waits between readings after a sort it backed off from.

Definition at line 94 of file locus_carcerum.h.

◆ MMGR_MOVABLE_IDLE_MAX_MS

#define MMGR_MOVABLE_IDLE_MAX_MS

The longest the mover waits between readings of a settled cellblock that no pass touched since the last reading. Each such reading doubles the wait up to this. A pass or a rise brings the next reading back to MMGR_MOVABLE_READ_MS.

Definition at line 101 of file locus_carcerum.h.

◆ MMGR_CARCER_REGIONS

#define MMGR_CARCER_REGIONS

The regions of the temporary tier: one stack of cells for each place the host gives a thread, modulo this count. 0 makes the temporary tier one stack that every thread shares.

Note
A take goes to the region that the thread's place selects, embed_thread_place() modulo this count. A give goes to the region that holds the cell, from any thread. A region's depth never passes MMGR_CARCER_REGION_BYTES. A take the region cannot hold sweeps the region, takes the last free run that holds it, and else goes to the large region, where the build declares one, which refuses it the same way. theory/locus_carcerum/LocusCarcerum/Regions.lean proves the bound, and Stacks.lean proves the sinking of one shared stack that the regions stop.
The regions lie at the top of the cellblock, MMGR_CARCER_REGION_AREA bytes in all, and the gap lies below them. A take over a region's room goes to the large region, MMGR_CARCER_LARGE_REGION_BYTES, where the build declares one. The host defines embed_thread_place beside embed_clock_ns, as embed_turnstile.h says.

Definition at line 119 of file locus_carcerum.h.

◆ MMGR_CARCER_REGION_BYTES

#define MMGR_CARCER_REGION_BYTES

Bytes of each region: its cells with their headers and owner words. A multiple of MMGR_CARCER_ALIGN.

Note
The max payload of one temporary take is this less a cell's two words.

Definition at line 128 of file locus_carcerum.h.

◆ MMGR_CARCER_LARGE_REGION_BYTES

#define MMGR_CARCER_LARGE_REGION_BYTES

Bytes of the one large region, at the top of the cellblock, that every temporary take over a region's room goes to, from any thread. 0 refuses such a take.

Note
The large region is one more region, the last, shared by every thread. A take goes there where its payload and its two words do not fit MMGR_CARCER_REGION_BYTES. Its depth never passes this size. Threads share it, so it sinks as one shared stack does, to this size at most, and the sweep then reclaims it.

Definition at line 140 of file locus_carcerum.h.

◆ MMGR_CARCER_LARGE_REGIONS

#define MMGR_CARCER_LARGE_REGIONS

1 where the cellblock has the large region, 0 where it has none.

Definition at line 144 of file locus_carcerum.h.

◆ MMGR_CARCER_REGION_COUNT

#define MMGR_CARCER_REGION_COUNT

The regions in all: one for each place, and the large one where the build declares it.

Definition at line 147 of file locus_carcerum.h.

Referenced by mmgr_series_cellularum_regions_idle().

◆ MMGR_CARCER_REGION_AREA

#define MMGR_CARCER_REGION_AREA

Bytes the regions take off the top of every cellblock, 0 where the temporary tier is one stack.

Definition at line 150 of file locus_carcerum.h.

Referenced by mmgr_series_cellularum_idle().

◆ MMGR_CARCER_ALIGN

#define MMGR_CARCER_ALIGN

Alignment of every prisoner on the way out: one machine word, or the atomic size word's alignment where that is wider.

Note
Derived from the two types in place of a number. Every cell carries an atomic size word at its header and at its foot. A cell's offset and payload are whole multiples of this, and each of those words lands at its own alignment at every width.
LocusCarcerum() puts this alignment on the storage it declares. This rounds only the offsets inside a cellblock.
EMBED_ALIGNOF is _Alignof in C and alignof in C++, the language nvcc compiles.

Definition at line 168 of file locus_carcerum.h.

◆ MMGR_OWNER_PLACE_BITS

#define MMGR_OWNER_PLACE_BITS

The owner word a cell carries behind its payload, one machine word positioned as fields, high to low. The fields are the owner's place in the table, the completion bit, the signal bits, and the nanosecond of the take. The clock is the library's, and the nanosecond rolls over its bits.

Note
The owner test is one AND: the word's place field against an owner's place. A word whose place field is 0 names no owner, as a free cell's does. The one context whose swap lands sets the completion bit once, when the cell's bytes come off its owner. Two gives that reach the same cell count it off once between them. The signal bits are the cellblock's to raise and read with one atomic step each. The timestamp is what the cell's take read on mmgr_carcer_hw_clock_ns, in the bits left, and a reader of lifetimes knows it rolls over.
MMGR_CARCER_OWNERS sizes the place field: the fewest bits every owner's place fits, from 4 to 16. Then come 1 completion bit, 3 signal bits, and the timestamp in the bits left, the word's width less those. 1024 owners on a 64-bit word leave 49 timestamp bits. On a 32-bit word they leave 17, which roll over every 131 microseconds, and on a 16-bit word 1. The layout fails the build where the word has no timestamp bit.

Definition at line 255 of file locus_carcerum.h.

◆ MMGR_OWNER_SIGNAL_BITS

#define MMGR_OWNER_SIGNAL_BITS

Definition at line 283 of file locus_carcerum.h.

◆ MMGR_OWNER_TIME_BITS

#define MMGR_OWNER_TIME_BITS

Definition at line 286 of file locus_carcerum.h.

◆ MMGR_OWNER_TIME_MASK

#define MMGR_OWNER_TIME_MASK

Definition at line 287 of file locus_carcerum.h.

◆ MMGR_OWNER_SIGNAL_SHIFT

#define MMGR_OWNER_SIGNAL_SHIFT

Definition at line 288 of file locus_carcerum.h.

◆ MMGR_OWNER_COMPLETE

#define MMGR_OWNER_COMPLETE

Definition at line 289 of file locus_carcerum.h.

◆ MMGR_OWNER_PLACE_SHIFT

#define MMGR_OWNER_PLACE_SHIFT

Definition at line 290 of file locus_carcerum.h.

◆ MMGR_OWNER_PLACE_MASK

#define MMGR_OWNER_PLACE_MASK

Definition at line 291 of file locus_carcerum.h.

◆ MMGR_OWNER_PLACE

#define MMGR_OWNER_PLACE ( name_,
text_ )

One owner's place in the table, counted from 0, as the enumeration MMGR_OWNERS positions names it.

Parameters
[in]name_The owner's identity, as declared.
[in]text_The owner's name as a reader prints it, unread here.

Definition at line 321 of file locus_carcerum.h.

◆ MMGR_OWNER_RECORD

#define MMGR_OWNER_RECORD ( name_,
text_ )

One owner's record as the table's initializer positions it: its name, its place from 1, nothing counted.

Parameters
[in]name_The owner's identity, as declared.
[in]text_The owner's name as a reader prints it [BORROWS].

Definition at line 329 of file locus_carcerum.h.

◆ MMGR_OWNER_POINTER

#define MMGR_OWNER_POINTER ( name_,
text_ )

One owner's identity defined: a const pointer to its record in the table, resolved by the linker.

Parameters
[in]name_The owner's identity, as declared.
[in]text_The owner's name as a reader prints it, unread here.
Note
EMBED_PASS_LOCAL gives each pass of nvcc its own identity, which points into the table of that pass.
Warning
Under nvcc the identity is local to the unit that expands MMGR_OWNERS, as EMBED_PASS_LOCAL states.

Definition at line 340 of file locus_carcerum.h.

◆ MMGR_OWNER_EXTERN

#define MMGR_OWNER_EXTERN ( name_,
text_ )

One owner's identity declared, for the header the owner's module reads it through.

Parameters
[in]name_The owner's identity, as declared.
[in]text_The owner's name as a reader prints it, unread here.

Definition at line 349 of file locus_carcerum.h.

◆ MMGR_OWNERS

#define MMGR_OWNERS ( list_)

The program's owners declared as data: the table positioned, its count, and each owner's identity defined.

Parameters
[in]list_The program's list of owners, a macro that takes one macro and applies it to each owner. The form list_(macro_) expands to macro_(name_, text_) for every owner. Here name_ is the identity the owner's module names and text_ the name a reader prints.
Note
Expanded once, in the translation unit that owns the program's memory. The enumeration gives each owner its place. The table has room for the owners declared and holds their records in that order. Each identity is a pointer into it that the linker resolves: there is no registration and nothing runs before the first take. A list longer than MMGR_CARCER_OWNERS fails the build.
EMBED_PASS_OBJECT defines the table and its count, and under nvcc their device twins from the same initializers.
The initializer sets the extent of the table, one record for each owner. The host pass of nvcc declares the device twin again at the declaration in this header, where the enumeration does not exist yet, and so the extent names no enumerator.

Definition at line 367 of file locus_carcerum.h.

◆ MMGR_CARCER_HALF_BITS

#define MMGR_CARCER_HALF_BITS

The bits each boundary has in the word that carries both, half the atomic size word, and the mask of a half.

Definition at line 427 of file locus_carcerum.h.

◆ MMGR_CARCER_HALF_MASK

#define MMGR_CARCER_HALF_MASK

Definition at line 428 of file locus_carcerum.h.

◆ MMGR_CARCER_BYTES_MAX

#define MMGR_CARCER_BYTES_MAX

The reach of a position in a boundary half: half the half's values. The other half is the headroom the bumps a round refuses move the position into before the next writer settles it.

Note
A bump up reads its position at or below this before its fetch-add, and a temporary position past it is a bump down that wrapped. A cell's header carries a size this large in the bits above its two state bits.

Definition at line 437 of file locus_carcerum.h.

◆ MMGR_CARCER_WANT_MAX

#define MMGR_CARCER_WANT_MAX

The max payload one bump may ask. It is the headroom the bumps in flight on the turnstiles' lanes share. Each of them may move its boundary once past MMGR_CARCER_BYTES_MAX before the refusal stops the rest. A take past it goes to the writer's path at once.

Definition at line 444 of file locus_carcerum.h.

◆ MMGR_CARCER_BANK_SHIFT

#define MMGR_CARCER_BANK_SHIFT

The bits of a bank's bytes: a bank is half the reach of a position. A test build can set fewer, so that a small pool spans many banks.

Note
A pool is a run of banks, and bank k starts at k shifted left by this. Each tier's position counts from the base of its frame, a bank, which the closed word names. A position reaches MMGR_CARCER_BYTES_MAX, so a tier crosses into the next bank with no writer. A writer that stores a boundary picks the frame that leaves the position a bank of room, at most MMGR_CARCER_FRAME_CAP. A pass reads the frames in its one read of the closed word. A writer reads them in its fetch-or of the closed bit. theory/locus_carcerum/LocusCarcerum/Banks.lean proves the frames.

Definition at line 458 of file locus_carcerum.h.

◆ MMGR_CARCER_BANK_BYTES

#define MMGR_CARCER_BANK_BYTES

The bytes of one bank.

Definition at line 462 of file locus_carcerum.h.

◆ MMGR_CARCER_BANK_FIELD_BITS

#define MMGR_CARCER_BANK_FIELD_BITS

The bits of each field of the closed word above its four flag bits. The fields are the bank count, the frame of the persistent tier and the frame of the temporary tier, in that order.

Definition at line 468 of file locus_carcerum.h.

◆ MMGR_CARCER_BANK_FIELD_MASK

#define MMGR_CARCER_BANK_FIELD_MASK

The mask of one field, at bit 0.

Definition at line 471 of file locus_carcerum.h.

Referenced by mmgr_series_cellularum_banks().

◆ MMGR_CARCER_BANK_COUNT_AT

#define MMGR_CARCER_BANK_COUNT_AT

The bit of the closed word that each field starts at.

Definition at line 475 of file locus_carcerum.h.

Referenced by mmgr_series_cellularum_banks().

◆ MMGR_CARCER_BANK_END_AT

#define MMGR_CARCER_BANK_END_AT

Definition at line 476 of file locus_carcerum.h.

◆ MMGR_CARCER_BANK_TOP_AT

#define MMGR_CARCER_BANK_TOP_AT

Definition at line 477 of file locus_carcerum.h.

◆ MMGR_CARCER_POOL_BYTES_MAX

#define MMGR_CARCER_POOL_BYTES_MAX

The max bytes one cellblock may hold: one less than the values of a field, times the bytes of a bank. So every frame and the bank count fit their fields.

Note
LocusCarcerum() asserts each pool against this, and mmgr_series_cellularum_placed refuses a pool past it.

Definition at line 485 of file locus_carcerum.h.

◆ MMGR_CARCER_BANK_OF

#define MMGR_CARCER_BANK_OF ( off_)

The bank an offset is in.

Definition at line 489 of file locus_carcerum.h.

◆ MMGR_CARCER_BANK_COUNT

#define MMGR_CARCER_BANK_COUNT ( bytes_)

The banks a cellblock of bytes_ bytes takes: its bytes rounded up to a whole bank.

Definition at line 492 of file locus_carcerum.h.

◆ MMGR_CARCER_FRAME_CAP

#define MMGR_CARCER_FRAME_CAP ( bytes_)

The highest frame of a cellblock of bytes_ bytes: two banks below its bank count, or bank 0.

Note
A position from this frame reaches the cellblock's end. So a cellblock of two banks or less keeps both frames at bank 0, and its writer never changes them (Banks.frames_still).

Definition at line 500 of file locus_carcerum.h.

◆ MMGR_CARCER_END_FRAME

#define MMGR_CARCER_END_FRAME ( end_,
bytes_ )

The frame a writer gives a persistent end in a cellblock of bytes_ bytes: the end's bank, or the cap.

Definition at line 504 of file locus_carcerum.h.

◆ MMGR_CARCER_BANK_BELOW

#define MMGR_CARCER_BANK_BELOW ( top_)

The bank below a top's own bank, or bank 0.

Definition at line 509 of file locus_carcerum.h.

◆ MMGR_CARCER_TOP_FRAME

#define MMGR_CARCER_TOP_FRAME ( top_,
bytes_ )

The frame a writer gives a temporary top in a cellblock of bytes_ bytes: the bank below the top's own, or the cap.

Definition at line 515 of file locus_carcerum.h.

◆ MMGR_CARCER_CLOSED_AT_REST

#define MMGR_CARCER_CLOSED_AT_REST ( bytes_)

The closed word of a cellblock at rest over bytes_ bytes. It holds no flag, the bank count, the persistent frame at bank 0, and the temporary frame for the top at the regions' start.

Definition at line 523 of file locus_carcerum.h.

◆ MMGR_CARCER_BOUNDS_AT_REST

#define MMGR_CARCER_BOUNDS_AT_REST ( bytes_)

The boundary word of a cellblock at rest over bytes_ bytes: the end at 0, the top's position in its frame.

Definition at line 530 of file locus_carcerum.h.

◆ MMGR_CARCER_STATE_HW

#define MMGR_CARCER_STATE_HW

The high-water members' first values, or nothing where the build tracks none.

Definition at line 607 of file locus_carcerum.h.

◆ MMGR_CARCER_STATE_REGIONS

#define MMGR_CARCER_STATE_REGIONS

The regions' first depths, every one 0, or nothing where the temporary tier is one stack.

Definition at line 620 of file locus_carcerum.h.

◆ MMGR_CARCER_STATE_TURNSTILES

#define MMGR_CARCER_STATE_TURNSTILES

The turnstiles' first values: each lane word, the top open lane and the queue length at 0.

Note
Each level of EmbedTurnstiles has its own brace: the struct, the array of lanes, one lane and its word. A bare {0} inside an initializer is a -Wmissing-braces finding, and -Wall turns that warning on in C.

Definition at line 629 of file locus_carcerum.h.

◆ MMGR_CARCER_STATE

#define MMGR_CARCER_STATE ( base_,
bytes_ )

A cellblock's state as it is over bytes_ bytes at base_ with no cell taken. Both tiers are empty, every mark is at zero, and the zero fill of the storage covers the turnstiles.

Parameters
[in]base_First byte of the cellblock [BORROWS].
[in]bytes_Bytes in the cellblock.
Note
The temporary top starts at the regions' start, which is the cellblock's size where there is no region. The closed word starts with the bank count and the frames of that top and of an end at 0.

Definition at line 640 of file locus_carcerum.h.

◆ MMGR_CARCER_STATE_HOSPES

#define MMGR_CARCER_STATE_HOSPES

The record of a cellblock over a hospes pool before the program places it: no base, no size, both boundaries at 0, so every take is refused until mmgr_series_cellularum_placed gives the storage.

Definition at line 658 of file locus_carcerum.h.

◆ MMGR_MOVABLE_HEAD_BYTES

#define MMGR_MOVABLE_HEAD_BYTES

Bytes of the option's state ahead of its turnstiles, which locus_carcerum.c asserts it fits.

Definition at line 732 of file locus_carcerum.h.

◆ MMGR_MOVABLE_CLAIM_BITS

#define MMGR_MOVABLE_CLAIM_BITS

The bits of one word of the option's claim bits: one an entry.

Definition at line 735 of file locus_carcerum.h.

◆ MMGR_MOVABLE_STORAGE_BYTES

#define MMGR_MOVABLE_STORAGE_BYTES ( cells_,
width_,
rows_ )

The storage the movable option takes for a table of cells_ entries and rows_ rows of touches.

Parameters
[in]cells_Movable cells the table can name at once.
[in]width_The lanes open bound the mover reads quiet under, which takes no storage.
[in]rows_Rows of touches.
Note
A constant expression, so that a pool declaration can use this size. The size covers the state, one word an entry, one claim bit an entry in whole words, and two words a row.

Definition at line 746 of file locus_carcerum.h.

◆ MMGR_GUARD_MOVABLE_TAKE_MEMBERS

#define MMGR_GUARD_MOVABLE_TAKE_MEMBERS

The two movable members both guards hold ahead of their movable release.

Note
movable_init assigns the movable option, once. movable_buf_alloc takes a cell a move may move: its identity, NULL where refused.

Definition at line 886 of file locus_carcerum.h.

◆ MMGR_GUARD_MOVABLE_SPAN_MEMBERS

#define MMGR_GUARD_MOVABLE_SPAN_MEMBERS

The four movable members both guards hold after their movable release.

Note
movable_buf_read copies out of a movable cell, and movable_buf_write copies into it. movable_buf_compare orders a movable cell's bytes. movable_buf_measure counts the bytes before a movable cell's next zero.

Definition at line 896 of file locus_carcerum.h.

◆ MMGR_GUARD_MEMBER_NAMES

#define MMGR_GUARD_MEMBER_NAMES

The thirteen member names of both guards, in their order, for EMBED_TABLE_LAYOUT.

Definition at line 905 of file locus_carcerum.h.

◆ MMGR_CARCER_MOVABLE_ENTRIES

#define MMGR_CARCER_MOVABLE_ENTRIES ( prisonsite_,
name_,
wipe_to_zero_on_release_,
series_cellularum_ )

The movable entries of one cellblock, bound to it through series_cellularum_.

Parameters
[in]prisonsite_Site whose name every entry symbol carries.
[in]name_Pool whose name the symbols carry alongside the site's.
[in]wipe_to_zero_on_release_Security flag, which the option retains for its releases and moves.
[in]series_cellularum_The cellblock's record, as a pointer expression.

Definition at line 982 of file locus_carcerum.h.

◆ MMGR_CARCER_BODY

#define MMGR_CARCER_BODY ( prisonsite_,
type_,
name_,
wipe_to_zero_on_release_,
hospes_ )

Everything one cellblock is: its bytes, its state, and the entries bound to it.

Parameters
[in]prisonsite_Site of the cellblock, which every emitted symbol carries.
[in]type_MinimumSecurityGuard or MaxSecurityGuard, read by MMGR_CARCER_MEM.
[in]name_Pool under the cellblock, which is also its name as a member of its site [BORROWS].
[in]wipe_to_zero_on_release_1 where a release zeroes the cell first, 0 where it does not.
[in]hospes_1 where the pool is a hospes pool the program places at run time, 0 where its storage is the array its declaration emitted.
Note
The site name is part of every symbol. Two sites may each hold a cellblock of the same name, at different security levels, with no collision.
wipe_to_zero_on_release_ is a literal: the branch it guards folds away and the security level costs nothing to read. hospes_ is a literal as well: it selects the record's initializer.
The extent comes from the pool two ways. The count name_##_bytes is the one its declaration received and is what the record carries, and sizeof is what the compiler positioned down. The asserts test the second: they say something the first cannot say about itself. A hospes pool has neither: its record starts empty, and mmgr_series_cellularum_placed tests the extent it is given.
Warning
A pool too small to hold one cell fails the build. Only the alignment is a power of two, and nothing reads the size as a mask. A bad size is a mistake the language would otherwise accept. A wrong name or guard type fails on its own. Two pools are separate objects: they cannot share an address and there is no overlap to check.
Note
No upper bound. The pool states how much storage the cellblock gets, and nothing in the library sizes anything from a ceiling over it.

Definition at line 1039 of file locus_carcerum.h.

◆ MMGR_CARCER_STORAGE_0

#define MMGR_CARCER_STORAGE_0 ( prisonsite_,
name_ )

A cellblock's record over the array its pool's declaration emitted: the asserts on the array's extent, and the record with the array as its base and the pool's count as its size.

Parameters
[in]prisonsite_Site of the cellblock, which the record's symbol carries.
[in]name_Pool under the cellblock.

Definition at line 1099 of file locus_carcerum.h.

◆ MMGR_CARCER_STORAGE_1

#define MMGR_CARCER_STORAGE_1 ( prisonsite_,
name_ )

A cellblock's record over a hospes pool: empty until the program places it.

Parameters
[in]prisonsite_Site of the cellblock, which the record's symbol carries.
[in]name_Pool under the cellblock.

Definition at line 1113 of file locus_carcerum.h.

◆ MMGR_CARCER_MEM

#define MMGR_CARCER_MEM ( prisonsite_,
type_,
name_,
wipe_to_zero_on_release_,
hospes_ )

One cellblock as a member of its site's type.

Parameters
[in]prisonsite_Site of the cellblock, unused here.
[in]type_MinimumSecurityGuard or MaxSecurityGuard, the member's type.
[in]name_Pool under the cellblock, and the name of the member.
[in]wipe_to_zero_on_release_Security flag, unused here.
[in]hospes_Hospes flag, unused here.
Note
Takes all five because the three readers share one tuple shape, as MMGR_MINIMUM_SECURITY describes.

Definition at line 1127 of file locus_carcerum.h.

◆ MMGR_CARCER_SEAT

#define MMGR_CARCER_SEAT ( prisonsite_,
type_,
name_,
wipe_to_zero_on_release_,
hospes_ )

One cellblock's entries, in the order its guard declares them.

Parameters
[in]prisonsite_Site whose name every entry symbol carries.
[in]type_Guard type, unused here.
[in]name_Pool whose name the symbols carry alongside the site's.
[in]wipe_to_zero_on_release_Security flag, unused here.
[in]hospes_Hospes flag, unused here.
Note
MinimumSecurityGuard and MaxSecurityGuard declare the same thirteen members in the same order. One initializer serves either level.

Definition at line 1140 of file locus_carcerum.h.

◆ MMGR_MINIMUM_SECURITY

#define MMGR_MINIMUM_SECURITY ( name_)

Declares a minimum security cellblock over a pool.

Parameters
[in]name_Pool under the cellblock, which is also its name as a member of its site [BORROWS].
Note
The pool carries its own extent: no size appears here. A cellblock is a layer over bytes that already exist. Which of ParsMemoriaeInternae or ParsMemoriaeExternum declared the bytes settles where they live.
Expands to a tuple in place of code. The site reads the same list three times, once for the cellblocks' bodies, once for its own members, once for their entries. An element has to stay data until the site says which of the three readings it gets.
The tuple's last element says whether the pool is a hospes pool: 0 here, the storage the array the pool's declaration emitted.

Definition at line 1163 of file locus_carcerum.h.

◆ MMGR_MAXIMUM_SECURITY

#define MMGR_MAXIMUM_SECURITY ( name_)

Declares a max security cellblock over a pool.

Parameters
[in]name_Pool under the cellblock, which is also its name as a member of its site [BORROWS].
Note
The 1 after the name is the wipe flag MMGR_CARCER_BODY reads to pick the release that zeroes on both tiers. The choice of this over MMGR_MINIMUM_SECURITY settles a cellblock's level, and nothing after the declaration can change it.
Carries no size, for the reason MMGR_MINIMUM_SECURITY gives.

Definition at line 1175 of file locus_carcerum.h.

◆ MMGR_MINIMUM_SECURITY_HOSPES

#define MMGR_MINIMUM_SECURITY_HOSPES ( name_)

Declares a minimum security cellblock over a hospes pool, one ParsMemoriaeHospes declared: the program gives the storage once, with mmgr_series_cellularum_placed, before the first take.

Parameters
[in]name_Hospes pool under the cellblock, which is also its name as a member of its site [BORROWS].
Note
The cellblock refuses every take until it is placed. The storage comes from the system, outside the program's image, where a program wants the pages a take touched given back while no cell holds them.

Definition at line 1186 of file locus_carcerum.h.

◆ MMGR_MAXIMUM_SECURITY_HOSPES

#define MMGR_MAXIMUM_SECURITY_HOSPES ( name_)

Declares a max security cellblock over a hospes pool, as MMGR_MINIMUM_SECURITY_HOSPES with the wipe on release.

Parameters
[in]name_Hospes pool under the cellblock [BORROWS].

Definition at line 1194 of file locus_carcerum.h.

◆ MMGR_UNTUPLE

#define MMGR_UNTUPLE ( ...)

Strips a tuple's parentheses.

Parameters
[in]...The tuple's elements, which its own parentheses deliver as this macro's arguments.
Returns
Those elements, comma separated, with nothing around them.
Note
Written MMGR_UNTUPLE tuple_, with no parentheses of its own: the tuple supplies them.

Definition at line 1203 of file locus_carcerum.h.

◆ MMGR_CARCER_APPLY

#define MMGR_CARCER_APPLY ( what_,
prisonsite_,
tuple_ )

Applies one reader to one cellblock tuple, with the site spliced in ahead of it.

Parameters
[in]what_Reader to apply: MMGR_CARCER_BODY, MMGR_CARCER_MEM or MMGR_CARCER_SEAT.
[in]prisonsite_Site, which reaches the reader ahead of the tuple's own elements.
[in]tuple_One MMGR_MINIMUM_SECURITY or MMGR_MAXIMUM_SECURITY tuple.
Returns
What the reader expands to.
Note
Two steps, because the preprocessor counts a macro's arguments before it expands them. The inner call lets the flattened tuple reach the reader as separate arguments.

Definition at line 1215 of file locus_carcerum.h.

◆ MMGR_CARCER_APPLY_

#define MMGR_CARCER_APPLY_ ( what_,
prisonsite_,
... )

Expands to what_(prisonsite_, VA_ARGS).

Parameters
[in]what_Reader to apply.
[in]prisonsite_Site, which reaches the reader ahead of the elements.
[in]...The tuple's elements, already flattened by MMGR_UNTUPLE.
Returns
What the reader expands to.
Note
The inner half of MMGR_CARCER_APPLY's two steps. The preprocessor expands its arguments before it puts them in. MMGR_UNTUPLE runs here and the tuple's elements reach the reader as separate arguments in place of one.

Definition at line 1228 of file locus_carcerum.h.

◆ MMGR_CARCER_W1

#define MMGR_CARCER_W1 ( what_,
prisonsite_,
SeriesCellularum1_ )

Applies the reader to a site's one cellblock tuple.

Parameters
[in]what_Reader to apply: MMGR_CARCER_BODY, MMGR_CARCER_MEM or MMGR_CARCER_SEAT.
[in]prisonsite_Site, which reaches the reader ahead of the tuple's own elements.
[in]SeriesCellularum1_The cellblock's tuple.
Note
The base of the expansion. Every longer line ends in this one, and it alone names no other.

Definition at line 1238 of file locus_carcerum.h.

◆ MMGR_CARCER_W2

#define MMGR_CARCER_W2 ( what_,
prisonsite_,
SeriesCellularum1_,
SeriesCellularum2_ )

Applies the reader to a site's two cellblock tuples.

Parameters
[in]what_Reader to apply.
[in]prisonsite_Site, which reaches the reader with every tuple.
[in]SeriesCellularum1_First cellblock's tuple, which MMGR_CARCER_W1 takes.
[in]SeriesCellularum2_Second cellblock's tuple, applied after it.
Note
The step every longer line repeats: expand the line one shorter, then apply the reader once more. The preprocessor cannot step through a list: each cellblock count needs a line of its own.

Definition at line 1251 of file locus_carcerum.h.

◆ MMGR_CARCER_W3

#define MMGR_CARCER_W3 ( what_,
prisonsite_,
SeriesCellularum1_,
SeriesCellularum2_,
SeriesCellularum3_ )

Applies the reader to a site's three cellblock tuples.

Parameters
[in]what_Reader to apply.
[in]prisonsite_Site, which reaches the reader with every tuple.
[in]SeriesCellularum1_First cellblock's tuple.
[in]SeriesCellularum2_Second cellblock's tuple.
[in]SeriesCellularum3_Third cellblock's tuple, applied after MMGR_CARCER_W2 expands the first two.
Note
MMGR_CARCER_WALK selects this line for a site that declares three cellblocks.

Definition at line 1265 of file locus_carcerum.h.

◆ MMGR_CARCER_W4

#define MMGR_CARCER_W4 ( what_,
prisonsite_,
SeriesCellularum1_,
SeriesCellularum2_,
SeriesCellularum3_,
SeriesCellularum4_ )

Applies the reader to a site's four cellblock tuples.

Parameters
[in]what_Reader to apply.
[in]prisonsite_Site, which reaches the reader with every tuple.
[in]SeriesCellularum1_First cellblock's tuple.
[in]SeriesCellularum2_Second cellblock's tuple.
[in]SeriesCellularum3_Third cellblock's tuple.
[in]SeriesCellularum4_Fourth cellblock's tuple, applied after MMGR_CARCER_W3 expands the first three.
Note
MMGR_CARCER_WALK selects this line for a site that declares four cellblocks.

Definition at line 1280 of file locus_carcerum.h.

◆ MMGR_CARCER_W5

#define MMGR_CARCER_W5 ( what_,
prisonsite_,
SeriesCellularum1_,
SeriesCellularum2_,
SeriesCellularum3_,
SeriesCellularum4_,
SeriesCellularum5_ )

Applies the reader to a site's five cellblock tuples.

Parameters
[in]what_Reader to apply.
[in]prisonsite_Site, which reaches the reader with every tuple.
[in]SeriesCellularum1_First cellblock's tuple.
[in]SeriesCellularum2_Second cellblock's tuple.
[in]SeriesCellularum3_Third cellblock's tuple.
[in]SeriesCellularum4_Fourth cellblock's tuple.
[in]SeriesCellularum5_Fifth cellblock's tuple, applied after MMGR_CARCER_W4 expands the first four.
Note
MMGR_CARCER_WALK selects this line for a site that declares five cellblocks.

Definition at line 1297 of file locus_carcerum.h.

◆ MMGR_CARCER_W6

#define MMGR_CARCER_W6 ( what_,
prisonsite_,
SeriesCellularum1_,
SeriesCellularum2_,
SeriesCellularum3_,
SeriesCellularum4_,
SeriesCellularum5_,
SeriesCellularum6_ )

Applies the reader to a site's six cellblock tuples.

Parameters
[in]what_Reader to apply.
[in]prisonsite_Site, which reaches the reader with every tuple.
[in]SeriesCellularum1_First cellblock's tuple.
[in]SeriesCellularum2_Second cellblock's tuple.
[in]SeriesCellularum3_Third cellblock's tuple.
[in]SeriesCellularum4_Fourth cellblock's tuple.
[in]SeriesCellularum5_Fifth cellblock's tuple.
[in]SeriesCellularum6_Sixth cellblock's tuple, applied after MMGR_CARCER_W5 expands the first five.
Note
MMGR_CARCER_WALK selects this line for a site that declares six cellblocks.

Definition at line 1315 of file locus_carcerum.h.

◆ MMGR_CARCER_W7

#define MMGR_CARCER_W7 ( what_,
prisonsite_,
SeriesCellularum1_,
SeriesCellularum2_,
SeriesCellularum3_,
SeriesCellularum4_,
SeriesCellularum5_,
SeriesCellularum6_,
SeriesCellularum7_ )

Applies the reader to a site's seven cellblock tuples.

Parameters
[in]what_Reader to apply.
[in]prisonsite_Site, which reaches the reader with every tuple.
[in]SeriesCellularum1_First cellblock's tuple.
[in]SeriesCellularum2_Second cellblock's tuple.
[in]SeriesCellularum3_Third cellblock's tuple.
[in]SeriesCellularum4_Fourth cellblock's tuple.
[in]SeriesCellularum5_Fifth cellblock's tuple.
[in]SeriesCellularum6_Sixth cellblock's tuple.
[in]SeriesCellularum7_Seventh cellblock's tuple, applied after MMGR_CARCER_W6 expands the first six.
Note
MMGR_CARCER_WALK selects this line for a site that declares seven cellblocks.

Definition at line 1335 of file locus_carcerum.h.

◆ MMGR_CARCER_W8

#define MMGR_CARCER_W8 ( what_,
prisonsite_,
SeriesCellularum1_,
SeriesCellularum2_,
SeriesCellularum3_,
SeriesCellularum4_,
SeriesCellularum5_,
SeriesCellularum6_,
SeriesCellularum7_,
SeriesCellularum8_ )

Applies the reader to a site's eight cellblock tuples.

Parameters
[in]what_Reader to apply.
[in]prisonsite_Site, which reaches the reader with every tuple.
[in]SeriesCellularum1_First cellblock's tuple.
[in]SeriesCellularum2_Second cellblock's tuple.
[in]SeriesCellularum3_Third cellblock's tuple.
[in]SeriesCellularum4_Fourth cellblock's tuple.
[in]SeriesCellularum5_Fifth cellblock's tuple.
[in]SeriesCellularum6_Sixth cellblock's tuple.
[in]SeriesCellularum7_Seventh cellblock's tuple.
[in]SeriesCellularum8_Eighth cellblock's tuple, applied after MMGR_CARCER_W7 expands the first seven.
Note
MMGR_CARCER_WALK selects this line for a site that declares eight cellblocks.
Warning
The last line written. A site that declares nine cellblocks pastes MMGR_CARCER_W9, which does not exist. That line is the whole fix. Nothing else changes and no configured ceiling has a part in it.

Definition at line 1359 of file locus_carcerum.h.

◆ MMGR_CARCER_WALK

#define MMGR_CARCER_WALK ( what_,
prisonsite_,
... )

Expands the walk that matches the cellblock count.

Parameters
[in]what_Reader to apply: MMGR_CARCER_BODY, MMGR_CARCER_MEM or MMGR_CARCER_SEAT.
[in]prisonsite_Site, forwarded to the walk ahead of the tuples.
[in]...MMGR_MINIMUM_SECURITY and MMGR_MAXIMUM_SECURITY tuples, one per cellblock.
Note
EMBED_CAT builds the line's name from EMBED_NARG's count of the tuples.
Warning
EMBED_NARG gives 1 for an empty list. A site that declares no cellblocks reaches MMGR_CARCER_W1 and fails there with too few arguments for the reader.

Definition at line 1376 of file locus_carcerum.h.

◆ LocusCarcerum

#define LocusCarcerum ( prisonsite_,
... )

Declares a prison site and the cellblocks built at it.

Parameters
[in]prisonsite_Name of the site. Its cellblocks are members of it.
[in]...MMGR_MINIMUM_SECURITY and MMGR_MAXIMUM_SECURITY declarations, one each.
Note
Everything it emits is data with its initial value. Nothing runs at startup, and a cellblock's first byte is the address of its own storage, which the linker resolves.
The warden is the const struct this emits under the site's name. Every call reaches a cellblock through it.
Every emitted symbol carries the site's name. A program may declare as many sites as it likes and two of them may each hold a cellblock called the same thing.
A cellblock's entries are bound to that cellblock. No call names one and none can reach another's bytes. A minimum security cellblock has no release that zeroes, and a max security one has no plain release.
Warning
The bytes, the state and the warden are all static. A declaration in a header gives every translation unit that includes it a site of its own in place of one they share.

Definition at line 1396 of file locus_carcerum.h.

Typedef Documentation

◆ CarcerMovableEntry

The identity a movable cell's taker holds: a const pointer to the cell's entry in the cellblock's translation table.

Note
The entry is the mutable word, and it is MMgr's alone: it names where the cell is now, and a move changes it. The pointer the caller holds never changes while the cell lives, however often the cell moves. No header a caller can reach declares the layout.

Definition at line 680 of file locus_carcerum.h.

◆ CarcerIdleEach

typedef void(*) CarcerIdleEach(void *context, void *at, size_t bytes)

A span of a cellblock's storage no cell holds, passed to the program: where it starts and its bytes.

Definition at line 1661 of file locus_carcerum.h.

Function Documentation

◆ mmgr_carcer_hw_clock_ns()

EMBED_HOST_DEVICE uint64_t mmgr_carcer_hw_clock_ns ( void )

The library's clock in nanoseconds, which a cell's owner word carries the take on.

Returns
The nanoseconds since a start the port chooses, which wrap at 2^64.
Note
Weak, and the default answers 0 every time: a build that defines none stamps every take 0. A port defines this name to replace it.

References mmgr_carcer_hw_clock_ns().

Referenced by mmgr_carcer_hw_clock_ns().

◆ EMBED_PASS_DECLARE()

EMBED_PASS_DECLARE ( CellOwner ,
mmgr_owner_table  )

The program's owner table and the owners in it, which MMGR_OWNERS defines once.

Note
A program that reaches a cellblock declares its owners with MMGR_OWNERS in one translation unit. A build with none fails at the link, and the link names these.
Under nvcc each has a device twin, with _device after its name, that MMGR_OWNERS defines from the same initializer. A read names it through EMBED_PASS_NAME, and so a kernel counts its cells in the device table.

References EMBED_PASS_DECLARE().

◆ mmgr_owner_listed()

EMBED_HOST_DEVICE embed_bool mmgr_owner_listed ( const CellOwner * owner)

Whether an owner is one of the table's.

Parameters
[in]ownerThe owner, which may be NULL [BORROWS].
Returns
EMBED_TRUE where it is the record at its own place in the table.

References mmgr_owner_listed().

Referenced by mmgr_owner_listed().

◆ mmgr_owner_in_use()

EMBED_HOST_DEVICE size_t mmgr_owner_in_use ( const CellOwner * owner)
inlinestatic

The payload bytes of the cells an owner has now.

Parameters
[in]ownerThe owner [BORROWS].
Returns
The bytes, off one word.

Definition at line 392 of file locus_carcerum.h.

References CellOwner::in_use, and mmgr_owner_in_use().

Referenced by mmgr_owner_in_use().

◆ mmgr_owner_hw()

EMBED_HOST_DEVICE size_t mmgr_owner_hw ( const CellOwner * owner)
inlinestatic

The max payload bytes an owner has had at once.

Parameters
[in]ownerThe owner [BORROWS].
Returns
The bytes, off one word.

Definition at line 404 of file locus_carcerum.h.

References CellOwner::hw, and mmgr_owner_hw().

Referenced by mmgr_owner_hw().

◆ mmgr_carcer_hw_misnamed()

EMBED_HOST_DEVICE void mmgr_carcer_hw_misnamed ( const CellOwner * named,
const CellOwner * cell_owner,
size_t bytes )

Told of each give or growth that names an owner other than the one the cell counts to.

Parameters
[in]namedThe owner the give or the growth named [BORROWS].
[in]cell_ownerThe owner the cell counts to, NULL where its owner word names no registered owner [BORROWS].
[in]bytesThe cell's payload bytes.
Note
Such a give or growth fails and changes nothing: the cell stays with its holder, counted to its owner. A program that sees this has a give in the wrong place, and a port logs it.
Weak, and the default does nothing. A port defines this name to replace it.

References mmgr_carcer_hw_misnamed().

Referenced by mmgr_carcer_hw_misnamed().

◆ mmgr_series_cellularum_persistent_end()

EMBED_HOST_DEVICE size_t mmgr_series_cellularum_persistent_end ( const SeriesCellularum * series)

Offset just past the last persistent cell.

Parameters
[in]seriesCellblock to read [BORROWS].
Returns
The persistent end, in bytes.
Note
The end as the word and its frame hold it, read under the epoch as one pair. A trim a give left owed on the open word does not run here; mmgr_buf_available and the next take run it.

References mmgr_series_cellularum_persistent_end().

Referenced by mmgr_series_cellularum_idle(), and mmgr_series_cellularum_persistent_end().

◆ mmgr_series_cellularum_temporary_top()

EMBED_HOST_DEVICE size_t mmgr_series_cellularum_temporary_top ( const SeriesCellularum * series)

Offset of the lowest temporary cell.

Parameters
[in]seriesCellblock to read [BORROWS].
Returns
The temporary top, in bytes.
Note
The top as the word and its frame hold it, read under the epoch as one pair. A trim a give left owed on the open word does not run here; mmgr_buf_available and the next take run it.

References mmgr_series_cellularum_temporary_top().

Referenced by mmgr_series_cellularum_idle(), and mmgr_series_cellularum_temporary_top().

◆ mmgr_series_cellularum_banks()

EMBED_HOST_DEVICE size_t mmgr_series_cellularum_banks ( const SeriesCellularum * series)
inlinestatic

The banks a cellblock's bytes take, as its closed word holds the count.

Parameters
[in]seriesCellblock to read [BORROWS].
Returns
The bank count, 0 over a hospes pool not yet placed.

Definition at line 777 of file locus_carcerum.h.

References SeriesCellularum::closed, MMGR_CARCER_BANK_COUNT_AT, MMGR_CARCER_BANK_FIELD_MASK, and mmgr_series_cellularum_banks().

Referenced by mmgr_series_cellularum_banks().

◆ mmgr_series_cellularum_region_depth()

EMBED_HOST_DEVICE size_t mmgr_series_cellularum_region_depth ( const SeriesCellularum * series,
size_t region )
inlinestatic

The bytes one region's stack holds from its end down.

Parameters
[in]seriesCellblock to read [BORROWS].
[in]regionThe region, below MMGR_CARCER_REGION_COUNT; the large region is the last.
Returns
The depth, in bytes, 0 where the temporary tier is one stack.

Definition at line 792 of file locus_carcerum.h.

References mmgr_series_cellularum_region_depth().

Referenced by mmgr_series_cellularum_region_depth(), and mmgr_series_cellularum_regions_idle().

◆ mmgr_series_cellularum_regions_idle()

EMBED_HOST_DEVICE embed_bool mmgr_series_cellularum_regions_idle ( const SeriesCellularum * series)
inlinestatic

Whether every region is empty.

Parameters
[in]seriesCellblock to read [BORROWS].
Returns
EMBED_TRUE where no region holds a cell, and where the temporary tier is one stack.

Definition at line 811 of file locus_carcerum.h.

References MMGR_CARCER_REGION_COUNT, mmgr_series_cellularum_region_depth(), and mmgr_series_cellularum_regions_idle().

Referenced by mmgr_series_cellularum_idle(), and mmgr_series_cellularum_regions_idle().

◆ mmgr_series_cellularum_idle()

EMBED_HOST_DEVICE embed_bool mmgr_series_cellularum_idle ( const SeriesCellularum * series)
inlinestatic

Whether a cellblock has no cell out.

Parameters
[in]seriesCellblock to read [BORROWS].
Returns
EMBED_TRUE where both tiers are empty.

Definition at line 836 of file locus_carcerum.h.

References MMGR_CARCER_REGION_AREA, mmgr_series_cellularum_idle(), mmgr_series_cellularum_persistent_end(), mmgr_series_cellularum_regions_idle(), mmgr_series_cellularum_temporary_top(), and SeriesCellularum::size.

Referenced by mmgr_series_cellularum_idle().

◆ mmgr_series_cellularum_persistent_hw()

EMBED_HOST_DEVICE size_t mmgr_series_cellularum_persistent_hw ( const SeriesCellularum * series)
inlinestatic

The furthest point of a cellblock's persistent tier so far.

Parameters
[in]seriesCellblock to read [BORROWS].
Returns
The bytes, 0 where the build tracks none (MMGR_ENABLE_HW_MEM_CAPACITY_CB).

Definition at line 852 of file locus_carcerum.h.

References mmgr_series_cellularum_persistent_hw().

Referenced by mmgr_series_cellularum_persistent_hw().

◆ mmgr_series_cellularum_temporary_hw()

EMBED_HOST_DEVICE size_t mmgr_series_cellularum_temporary_hw ( const SeriesCellularum * series)
inlinestatic

The max bytes a cellblock's temporary tier took from the top at one time.

Parameters
[in]seriesCellblock to read [BORROWS].
Returns
The bytes, 0 where the build tracks none (MMGR_ENABLE_HW_MEM_CAPACITY_CB).

Definition at line 869 of file locus_carcerum.h.

References mmgr_series_cellularum_temporary_hw().

Referenced by mmgr_series_cellularum_temporary_hw().

◆ mmgr_persistent_buf_alloc()

EMBED_HOST_DEVICE void * mmgr_persistent_buf_alloc ( SeriesCellularum * series,
size_t size,
const CellOwner * owner )

Takes size bytes from a cellblock's persistent tier.

Parameters
[in,out]seriesCellblock to take from [BORROWS].
[in]sizeBytes wanted.
[in]ownerThe registered owner that counts the cell [BORROWS].
Returns
Start of the cell, or NULL when owner is NULL or not registered or the cellblock cannot meet the take [RETURNS OWNERSHIP].
Note
Reached through the cellblock's own guard, never called by name.
A persistent cell is until the same cellblock's persistent_buf_release takes it.
A cell passed out adds its payload bytes, the request rounded to a word, to owner's in_use and raises owner's hw to it. A refused take counts nothing.
The take is one pass through the cellblock's turnstiles and one fetch-add on the persistent end. The cell is the bytes the bump covered, and its header and owner word go down once the take reads the room off the top. A bump the gap cannot meet adds its bytes to the tier's overrun. The take then closes the cellblock, drains the turnstiles and walks the tier alone.
The walk merges every run of free cells into one. It takes the first run that holds the take and splits it where its rest holds a cell. It returns the free run at the end to the gap, and bumps the gap where no run fits. Only then does the take fail, and no path branches on what another context did.
Warning
The bytes stay as they are, and a cell positioned over bytes a prisoner occupied before still carries what that prisoner left. A cellblock declared MMGR_MAXIMUM_SECURITY zeroes, and it zeroes on release.

References MMGR_ALLOC_SIZE, and mmgr_persistent_buf_alloc().

Referenced by mmgr_persistent_buf_alloc().

◆ mmgr_persistent_max_security_buf_alloc()

EMBED_HOST_DEVICE void * mmgr_persistent_max_security_buf_alloc ( SeriesCellularum * series,
size_t size,
const CellOwner * owner )

Takes size bytes from a max security cellblock's persistent tier.

Parameters
[in,out]seriesCellblock to take from [BORROWS].
[in]sizeBytes wanted.
[in]ownerThe registered owner that counts the cell [BORROWS].
Returns
As mmgr_persistent_buf_alloc answers [RETURNS OWNERSHIP].
Note
The take mmgr_persistent_buf_alloc makes. A max security cellblock zeroes on release.

References mmgr_persistent_max_security_buf_alloc().

Referenced by mmgr_persistent_max_security_buf_alloc().

◆ mmgr_persistent_buf_release()

EMBED_HOST_DEVICE void mmgr_persistent_buf_release ( SeriesCellularum * series,
void * prisoner,
const CellOwner * owner )

Releases a prisoner and leaves the cell's bytes as they are.

Parameters
[in,out]seriesCellblock the prisoner came from [BORROWS].
[in]prisonerFirst byte of the cell [TAKES OWNERSHIP].
[in]ownerThe owner the cell counts to, as its owner word names it [BORROWS].
Note
The cell's offset against the persistent end says which tier it lies in. A NULL prisoner or a NULL owner changes nothing.
The give is one fetch-or on the cell's owner word, which sets its completion bit, and one store on the cell's header, which goes free. The cell's payload bytes, read off its header, come off owner's in_use in the context whose fetch-or found the bit clear. A release that names an owner other than the cell's changes nothing, and mmgr_carcer_hw_misnamed hears of it. One of a cell given back already changes nothing either. No pass and no wait: the cell's words are its holder's alone.
A free cell stays in its tier for the compaction that a take the gap cannot meet runs. The compaction merges it with its free neighbors, takes it where it fits, or returns it to the gap where it reaches the end.
Warning
A prisoner outside this cellblock's own bytes stops the program with MMGR_FATAL: there is no state to carry on from.
prisoner is dead once this returns and its bytes stay as they are. The cellblock may hand them out again.
The bound is the cellblock's storage and never a cell boundary. An address inside these bytes that is not the first byte of a cell is still read as a cell's word.

References mmgr_persistent_buf_release().

Referenced by mmgr_persistent_buf_release().

◆ mmgr_persistent_max_security_buf_release()

EMBED_HOST_DEVICE void mmgr_persistent_max_security_buf_release ( SeriesCellularum * series,
void * prisoner,
const CellOwner * owner )

Zeroes a cell, then releases the prisoner.

Parameters
[in,out]seriesCellblock the prisoner came from [BORROWS].
[in,out]prisonerFirst byte of the cell, zeroed before release [TAKES OWNERSHIP].
[in]ownerThe owner the cell counts to, as its owner word names it [BORROWS].
Note
The extent comes from the cell's own header. A caller cannot under-zero a cell with a count of fewer bytes than it carries. A NULL prisoner or a NULL owner changes nothing.
The zero fill is the only step that separates this from mmgr_persistent_buf_release. It runs once the owner named proves to be the cell's and the cell still counts. A release that names another owner, or one of a cell given back already, zeroes nothing.
Warning
A prisoner outside this cellblock's own bytes stops the program with MMGR_FATAL.
prisoner is dead once this returns. The cellblock may hand those bytes out again.
The bound is the cellblock's storage and never a cell boundary. An address inside these bytes that is not the first byte of a cell still gets its extent from the bytes ahead of it. The zero fill then runs for whatever length those hold.

References MMGR_ALLOC_SIZE, and mmgr_persistent_max_security_buf_release().

Referenced by mmgr_persistent_max_security_buf_release().

◆ mmgr_buf_grow()

EMBED_HOST_DEVICE void * mmgr_buf_grow ( SeriesCellularum * series,
void * prisoner,
size_t size,
const CellOwner * owner )

Grows a cell to size payload bytes in place, where it is the newest cell of its tier.

Parameters
[in,out]seriesCellblock the prisoner came from [BORROWS].
[in,out]prisonerFirst byte of the cell [BORROWS].
[in]sizePayload bytes the cell is to carry, rounded as a take rounds them.
[in]ownerThe owner the cell counts to, as its owner word names it, which also counts the growth [BORROWS].
Returns
The cell's first byte after the growth: the prisoner itself for a persistent cell, or for one that carries size already. A temporary cell, whose bytes moved down, gets a lower address. NULL with nothing changed where the cell is not the newest of its tier, since a later take is above it. NULL also where the gap cannot meet the growth. A NULL prisoner, a NULL owner, or an owner other than the cell's returns NULL. The wrong owner reaches mmgr_carcer_hw_misnamed [RETURNS OWNERSHIP].
Note
The growth closes the cellblock, drains the turnstiles and works alone. The newest cell of a tier is the cell its boundary is against. That is the persistent end at the cell's end, or the temporary top at the cell's header. The growth reads the gap exactly, stores the boundary past the growth, and moves no other cell. A caller whose growth fails takes a larger cell, copies into it and releases the first, as it would without this entry.
The added bytes are as they lie, and mmgr_max_security_buf_grow zeroes them. A persistent growth's hold the word that was behind the payload, a temporary growth's the cell's own old header and payload.
Warning
The prisoner's address is dead after a temporary growth that answers a lower one: the answered address is the cell's from then on. A prisoner outside this cellblock's own bytes stops with MMGR_FATAL, as a release does.

References MMGR_ALLOC_SIZE, and mmgr_buf_grow().

Referenced by mmgr_buf_grow().

◆ mmgr_max_security_buf_grow()

EMBED_HOST_DEVICE void * mmgr_max_security_buf_grow ( SeriesCellularum * series,
void * prisoner,
size_t size,
const CellOwner * owner )

Grows a cell in place as mmgr_buf_grow does, and zeroes the bytes the growth adds.

Parameters
[in,out]seriesCellblock the prisoner came from [BORROWS].
[in,out]prisonerFirst byte of the cell [BORROWS].
[in]sizePayload bytes the cell is to carry.
[in]ownerThe owner that counts a persistent cell's growth [BORROWS].
Returns
As mmgr_buf_grow answers [RETURNS OWNERSHIP].
Note
The zero fill covers the growth's bytes alone: the payload the cell carried retains its bytes, moved for a temporary cell.

References mmgr_max_security_buf_grow().

Referenced by mmgr_max_security_buf_grow().

◆ mmgr_temporary_buf_alloc()

EMBED_HOST_DEVICE void * mmgr_temporary_buf_alloc ( SeriesCellularum * series,
size_t size,
const CellOwner * owner )

Takes size bytes from a cellblock's temporary tier.

Parameters
[in,out]seriesCellblock to take from [BORROWS].
[in]sizeBytes wanted.
[in]ownerThe registered owner that counts the cell [BORROWS].
Returns
Start of the cell, or NULL when owner is NULL or not registered or the cellblock cannot meet the take [RETURNS OWNERSHIP].
Note
The caller gives the cell back through mmgr_persistent_buf_release, as with a persistent cell, which takes the bytes off owner. The cell carries owner in the word behind its payload.
The take is mmgr_persistent_buf_alloc's with the arithmetic mirrored. It is one pass through the cellblock's turnstiles and one fetch-add on the temporary top, which moves it down by the cell. The take reads the room off the persistent end, and a bump that crosses it adds its bytes to the tier's overrun. The take then closes the cellblock, drains the turnstiles and walks the tier alone.
The walk merges every run of free cells into one. It takes the run that fits nearest the cellblock's size and splits it where its rest holds a cell. It returns the free run at the top to the gap, and bumps the top where no run fits. Only then does the take fail.
Warning
The bytes stay as they are, and an allocation returns whatever the last prisoner left. A cellblock declared MMGR_MAXIMUM_SECURITY zeroes, and it zeroes on release.

References MMGR_ALLOC_SIZE, and mmgr_temporary_buf_alloc().

Referenced by mmgr_temporary_buf_alloc().

◆ mmgr_temporary_max_security_buf_alloc()

EMBED_HOST_DEVICE void * mmgr_temporary_max_security_buf_alloc ( SeriesCellularum * series,
size_t size,
const CellOwner * owner )

Takes size bytes from a max security cellblock's temporary tier.

Parameters
[in,out]seriesCellblock to take from [BORROWS].
[in]sizeBytes wanted.
[in]ownerThe registered owner that counts the cell [BORROWS].
Returns
As mmgr_temporary_buf_alloc answers [RETURNS OWNERSHIP].
Note
The take mmgr_temporary_buf_alloc makes. A max security cellblock zeroes on release.

References mmgr_temporary_max_security_buf_alloc().

Referenced by mmgr_temporary_max_security_buf_alloc().

◆ mmgr_who_owns_buf()

EMBED_HOST_DEVICE embed_bool mmgr_who_owns_buf ( const SeriesCellularum * series,
const void * at )

Whether at lies inside the cellblock's bytes.

Parameters
[in]seriesCellblock to test against [BORROWS].
[in]atAddress to test [BORROWS].
Returns
EMBED_TRUE when at lies in the cellblock's storage, which is [base, base + size).
Note
One unsigned compare covers both ends, since an address below base wraps to a difference larger than any size.
Warning
Any address in the cellblock answers true, the first byte of a cell or any other. This says where an address is and nothing of what is there. A true answer is not a warrant for a release of at. The releases read a cell's word from whatever address they receive.

References mmgr_who_owns_buf().

Referenced by mmgr_who_owns_buf().

◆ mmgr_owner_of_buf()

EMBED_HOST_DEVICE const CellOwner * mmgr_owner_of_buf ( const SeriesCellularum * series,
const void * prisoner )

The owner a cell counts to, read off the word behind its payload.

Parameters
[in]seriesCellblock the prisoner came from [BORROWS].
[in]prisonerFirst byte of the cell [BORROWS].
Returns
The registered owner the cell's owner word names. NULL where prisoner is NULL, lies outside the cellblock, is a cell no context holds, or its word names no registered owner [BORROWS].
Note
A holder that grows or gives back a cell another part of the program took names the owner this answers. Such a line grows in the passes of whoever writes it.
Warning
The bound is the cellblock's storage and never a cell boundary, as for a release. An address inside these bytes that is not the first byte of a cell reads as a cell's word.

References mmgr_owner_of_buf().

Referenced by mmgr_owner_of_buf().

◆ mmgr_buf_available()

EMBED_HOST_DEVICE size_t mmgr_buf_available ( SeriesCellularum * series)

The bytes between the two tiers.

Parameters
[in,out]seriesCellblock to read [BORROWS].
Returns
The temporary top less the persistent end, read off one word.
Note
An allocation out of that gap needs a cell header from the same bytes, and the request rounds up to a whole word first. The gap cannot meet a request of exactly this many bytes.
The trims a give left owed on the open word run first, and the gap read has every owed trim run.
Warning
The answer is a snapshot. Any allocation at all leaves it stale before the caller can act on it.

References mmgr_buf_available().

Referenced by mmgr_buf_available().

◆ mmgr_zero_buf()

EMBED_HOST_DEVICE void mmgr_zero_buf ( void * prisoner,
size_t size )

Zeroes size bytes at prisoner and releases nothing.

Parameters
[in,out]prisonerFirst byte to clear [BORROWS].
[in]sizeBytes to clear.
Note
The stores are volatile: the compiler cannot drop a clear of bytes nothing reads afterwards as dead work. The middle goes a word at a time, the two edges a byte at a time.
The extent is the caller's to state. A release that zeroes takes it from the cell's own word.
Warning
prisoner must be writable for size bytes.

References mmgr_zero_buf().

Referenced by mmgr_zero_buf().

◆ mmgr_align_up_buf()

EMBED_HOST_DEVICE size_t mmgr_align_up_buf ( size_t size)

Rounds size up to a whole machine word.

Parameters
[in]sizeCount to round.
Returns
size rounded up to a multiple of MMGR_CARCER_ALIGN, and size itself when it already is one.
Note
A size of 0 rounds to 0. The allocators do not round a request this way. They carry a request of 0 up to one word first: no cell goes out empty.
Warning
The round adds MMGR_CARCER_ALIGN - 1 before the mask. A size within a word of SIZE_MAX wraps to 0.

References mmgr_align_up_buf().

Referenced by mmgr_align_up_buf().

◆ mmgr_series_cellularum_emptied()

EMBED_HOST_DEVICE void mmgr_series_cellularum_emptied ( SeriesCellularum * series)

Puts a cellblock back to the state of its declaration. Both tiers are empty, the closed word and the turnstiles at rest, the option unassigned, and no byte of its storage touched.

Parameters
[in,out]seriesCellblock to empty [BORROWS].
Note
Every cell the cellblock passed out is dead once this returns. A suite calls it between cases over one declared cellblock. A program with a cellblock to empty while another context reaches it has a cellblock whose cells that context still holds.
Nothing outside the tiers reads as a cell, and so no cell's words change.

References mmgr_series_cellularum_emptied().

Referenced by mmgr_series_cellularum_emptied().

◆ mmgr_series_cellularum_placed()

EMBED_HOST_DEVICE embed_bool mmgr_series_cellularum_placed ( SeriesCellularum * series,
uint8_t * storage,
size_t bytes )

Places a cellblock declared over a hospes pool on the storage the program gives: its base and its size set, and the cellblock emptied over them.

Parameters
[in,out]seriesCellblock to place [BORROWS].
[in]storageFirst byte of the storage, aligned to MMGR_ALIGN_BYTES [BORROWS].
[in]bytesBytes of the storage.
Returns
EMBED_TRUE where the cellblock is placed. EMBED_FALSE where storage is NULL, or the bytes are fewer than the regions and one cell need or more than MMGR_CARCER_POOL_BYTES_MAX. Then nothing changed, and the cellblock refuses every take as before.
Note
Called once, at a time no context reaches the cellblock, before its first take; the program keeps the storage for as long as the cellblock lives. A cellblock over an array its declaration emitted has its base from the linker and is never placed. theory/locus_carcerum/LocusCarcerum/Idle.lean proves that a cellblock of size 0 refuses every take.

References mmgr_series_cellularum_placed().

Referenced by mmgr_series_cellularum_placed().

◆ mmgr_series_cellularum_idle_each()

EMBED_HOST_DEVICE void mmgr_series_cellularum_idle_each ( SeriesCellularum * series,
CarcerIdleEach each,
void * context )

Passes each span of the cellblock's storage that no cell holds to each, with the cellblock closed: the gap between the tiers, and the room of each region above its depth.

Parameters
[in,out]seriesCellblock to read [BORROWS].
[in]eachThe call for each span, run with the cellblock closed.
[in]contextWhat each is passed first [BORROWS].
Note
The program gives a span's pages back to the system where it wishes, and the next take that reaches them reads what a page the system gives afresh holds. No cell's words lie in a span, and no take or give runs while the cellblock is closed, so a span the call reads is idle for as long as the call runs. theory/locus_carcerum/LocusCarcerum/Idle.lean proves that no byte of a span lies in a cell.
A free cell inside a tier, under a busy one, is no span: its words are the tier's.

References mmgr_series_cellularum_idle_each().

Referenced by mmgr_series_cellularum_idle_each().

◆ mmgr_owner_bytes_taken()

EMBED_HOST_DEVICE void mmgr_owner_bytes_taken ( const CellOwner * owner,
size_t bytes )

Counts bytes that lie in no cellblock to an owner, as a ring's or a page's are.

Parameters
[in]ownerThe registered owner [BORROWS].
[in]bytesThe bytes.
Note
An owner's counts are the program's total, and memory a program takes outside a cellblock belongs in it. No cellblock's own total moves.

References mmgr_owner_bytes_taken().

Referenced by mmgr_owner_bytes_taken().

◆ mmgr_owner_bytes_given()

EMBED_HOST_DEVICE void mmgr_owner_bytes_given ( const CellOwner * owner,
size_t bytes )

Takes bytes mmgr_owner_bytes_taken counted off their owner.

Parameters
[in]ownerThe owner that counted them [BORROWS].
[in]bytesThe bytes.

References mmgr_owner_bytes_given().

Referenced by mmgr_owner_bytes_given().

◆ mmgr_series_cellularum_fragmentation()

EMBED_HOST_DEVICE size_t mmgr_series_cellularum_fragmentation ( const SeriesCellularum * series)

A cellblock's fragmentation: the bytes its persistent tier occupies and no cell's payload holds, as a percentage of the bytes it occupies.

Parameters
[in]seriesCellblock to read [BORROWS].
Returns
The percentage, 0 to 100, read against the hundredth of the bytes occupied rounded up, and 0 below a hundred bytes occupied.
Note
Read off the persistent end and the tier's total, with no walk. Each cell's words count among the bytes no payload holds, and a tier of small cells reads some fragmentation with no free cell.
The temporary tier reads nothing: its cells last one call, and its top comes back as they end. A free cell no movable cell is above is no work for a mover either. The mover remembers a sort that finds nothing to move, and does not run it again until the reading rises.

References mmgr_series_cellularum_fragmentation().

Referenced by mmgr_series_cellularum_fragmentation().

◆ mmgr_movable_init()

EMBED_HOST_DEVICE embed_bool mmgr_movable_init ( SeriesCellularum * series,
const CarcerMovableInitCfg * args,
embed_bool wipes )

Assigns a cellblock's movable option: the translation table, its claim bits, the rows of touches and the mover's thread. A cellblock's guard calls this, as movable_init.

Parameters
[in,out]seriesCellblock the option serves [BORROWS].
[in]argsThe storage, the sizes and the thread's calls [BORROWS].
[in]wipesWhether a cell a move leaves or a release gives back gets a zero fill first.
Returns
EMBED_TRUE where the option is on and, where the caller gave a thread, the thread started. EMBED_FALSE where it is on already, the storage is short or a size is zero, nothing changed. EMBED_FALSE also where the thread did not start, which leaves the option on and nothing to move a cell.
Note
Assigned once, at a time no context reaches a movable cell. The cellblock's turnstiles are what the mover reads as occupancy: the lanes open against the option's width.

References mmgr_movable_init().

Referenced by mmgr_movable_init().

◆ mmgr_movable_buf_alloc()

EMBED_HOST_DEVICE const CarcerMovableEntry * mmgr_movable_buf_alloc ( SeriesCellularum * series,
size_t size,
const CellOwner * owner )

Takes a persistent cell a move may move, and names it in the table.

Parameters
[in,out]seriesCellblock to take from [BORROWS].
[in]sizeBytes wanted.
[in]ownerThe registered owner that counts the cell [BORROWS].
Returns
The cell's identity. NULL where the option is off, the cellblock cannot meet the take or the table has no free entry, nothing counted.
Note
The identity is a const pointer to the cell's entry. It is for the cell's life whatever moves the cell, and the movable_buf_ calls are the only way from it to the bytes.
Warning
A pointer retained past mmgr_movable_buf_release names an entry a later take may reuse.

References mmgr_movable_buf_alloc().

Referenced by mmgr_movable_buf_alloc().

◆ mmgr_movable_buf_release()

EMBED_HOST_DEVICE embed_bool mmgr_movable_buf_release ( SeriesCellularum * series,
const CarcerMovableEntry * cell,
const CellOwner * owner )

Gives a movable cell back and frees its entry.

Parameters
[in,out]seriesCellblock the cell is in [BORROWS].
[in]cellThe cell [BORROWS].
[in]ownerThe owner that counts the cell [BORROWS].
Returns
EMBED_TRUE where it went back. EMBED_FALSE where cell is NULL, the entry is free or owner is not the cell's, of which mmgr_carcer_hw_misnamed hears, nothing changed.
Note
One pass through the cellblock's turnstiles: the entry read, the cell given back as a release does, the entry's word and claim bit cleared. A move is a writer, which drains the passes before it and closes the cellblock to those after. The two never reach the entry at once.

References mmgr_movable_buf_release().

Referenced by mmgr_movable_buf_release().

◆ mmgr_movable_buf_read()

EMBED_HOST_DEVICE embed_bool mmgr_movable_buf_read ( const SeriesCellularum * series,
const CarcerMovableCfg * args )

Copies args->bytes from args->offset of a movable cell to args->dst.

Parameters
[in,out]seriesCellblock the cell is in [BORROWS].
[in]argsThe cell, offset, dst and bytes [BORROWS].
Returns
EMBED_TRUE where copied, EMBED_FALSE where the span passes the cell's end or the entry is free, nothing copied.
Note
Thin: one pass through the cellblock's turnstiles, badged with the id of the thread that calls. The entry's word read, the bytes copied, and the lane let go. A pass that finds the cellblock closed to a move backs off one step and tries once more.

References mmgr_movable_buf_read().

Referenced by mmgr_movable_buf_read().

◆ mmgr_movable_buf_write()

EMBED_HOST_DEVICE embed_bool mmgr_movable_buf_write ( SeriesCellularum * series,
const CarcerMovableCfg * args )

Copies args->bytes from args->src to args->offset of a movable cell.

Parameters
[in,out]seriesCellblock the cell is in [BORROWS].
[in]argsThe cell, offset, src and bytes [BORROWS].
Returns
As mmgr_movable_buf_read answers.
Note
Atomic against a move and not against another writer: two contexts that write the same bytes order themselves.

References mmgr_movable_buf_write().

Referenced by mmgr_movable_buf_write().

◆ mmgr_movable_buf_compare()

EMBED_HOST_DEVICE embed_iword mmgr_movable_buf_compare ( const SeriesCellularum * series,
const CarcerMovableCfg * args )

Orders args->bytes of a movable cell against args->src, or against another cell where args->other_cell holds one.

Parameters
[in,out]seriesCellblock the cell is in [BORROWS].
[in]argsThe cell, offset, and src or other_cell and other_offset, and bytes [BORROWS].
Returns
As memor.cmp orders them, and 1 where a span passes its cell's end or an entry is free.
Note
Two cells are the max one call reaches, both read under the one pass.

References mmgr_movable_buf_compare().

Referenced by mmgr_movable_buf_compare().

◆ mmgr_movable_buf_measure()

EMBED_HOST_DEVICE size_t mmgr_movable_buf_measure ( const SeriesCellularum * series,
const CarcerMovableCfg * args )

The bytes from args->offset of a movable cell to the next zero byte.

Parameters
[in,out]seriesCellblock the cell is in [BORROWS].
[in]argsThe cell and offset [BORROWS].
Returns
The bytes, or the bytes to the cell's end where no zero is before it.

References mmgr_movable_buf_measure().

Referenced by mmgr_movable_buf_measure().

◆ mmgr_movable_buf_move()

EMBED_HOST_DEVICE embed_bool mmgr_movable_buf_move ( SeriesCellularum * series)

Moves one movable cell into the first free cell below it, highest cell first.

Parameters
[in,out]seriesCellblock whose cells to move [BORROWS].
Returns
EMBED_TRUE where a cell moved. EMBED_FALSE where none could at this reading: no free run fits below any of them.
Note
The mover's step, a writer's. It closes the cellblock, drains the turnstiles, and reads the highest named cell. It walks the persistent tier below it for the first free run that holds the cell. It copies the cell, carries its owner word over, flips the entry to the copy, frees the cell left behind, and opens the cellblock. The same state moves the same cell to the same place.
Called until it answers EMBED_FALSE, the cells are as low as the free runs let them. The free run that reaches the tier's end returns to the gap with each walk.
The copy carries the cell's owner word, and so the owner's count is as it was through the move.
A cell no free run below takes rules out every cell at least its size under it. Those look through the same free runs for as much room.
Warning
Each cell moved, and each smaller size refused, costs a read of the named part of the table. It costs a walk of the tier below the cell too.

References mmgr_movable_buf_move().

Referenced by mmgr_movable_buf_move().

◆ mmgr_movable_run()

EMBED_HOST_DEVICE void mmgr_movable_run ( SeriesCellularum * series)

The mover: what the thread the program gave runs, until its thread_wait answers EMBED_FALSE.

Parameters
[in,out]seriesCellblock with the option assigned and thread_wait given [BORROWS].
Note
Each MMGR_MOVABLE_READ_MS it reads the cellblock, and fragmentation under MMGR_MOVABLE_SETTLE_PERCENT ends the reading. Over it, MMGR_MOVABLE_QUIET_READINGS in a row must find the cellblock quiet. Quiet is twice the lanes its turnstiles have open at or under the option's width plus one, with no pass since the last reading. It then moves cells one at a time, the cellblock open and the processor yielded between moves. It reads the same after each: a pass, or lanes open past quiet, says the moves meet pressure, and it backs off.
Each backoff doubles the wait, up to MMGR_MOVABLE_BACKOFF_MAX_MS. A sort that ends with nothing left to move resets the wait, and the mover remembers the fragmentation it left. Nothing runs again until the reading rises past that or falls under the threshold first.

References mmgr_movable_run().

Referenced by mmgr_movable_run().

◆ mmgr_movable_queue_depth()

EMBED_HOST_DEVICE size_t mmgr_movable_queue_depth ( const SeriesCellularum * series)

The contexts queued at the cellblock's turnstiles now: those that found every open lane busy and wait for a lane.

Parameters
[in]seriesCellblock to read [BORROWS].
Returns
The queued contexts, 0 without the option.

References mmgr_movable_queue_depth().

Referenced by mmgr_movable_queue_depth().

◆ mmgr_movable_touches()

EMBED_HOST_DEVICE embed_bool mmgr_movable_touches ( const SeriesCellularum * series,
size_t at,
size_t * id,
size_t * touches )

One row of touches a lane, counted as passes go through it.

Parameters
[in,out]seriesCellblock to read [BORROWS].
[in]atThe row, from 0: the lane of the same place.
[out]idThe id of the last badge through the lane. That is an owner's place, or a thread's id plus one for a pass that names no owner [BORROWS].
[out]touchesThe passes through the lane so far [BORROWS].
Returns
EMBED_TRUE where the row holds a lane's passes, EMBED_FALSE past the rows in use or for a lane with no pass through it yet.
Note
A telemetry row, counted by one add as each pass badges in, and nothing decides on it. The option's last row counts every lane past the rest, and answers an id of SIZE_MAX.

References mmgr_movable_touches().

Referenced by mmgr_movable_touches().