Skip to main content

Crate alloc_kern

Crate alloc_kern 

Source
Expand description

§Allocator — Physical & Virtual Memory Manager

This module implements a no_std memory allocator supporting:

  • physical frame allocation
  • virtual segmentation
  • fragmentation handling
  • safe read/write IO
  • quarantine anti‑leak system

§Design overview

  • pos is a byte offset in virtual memory
  • segments do not overlap for a given process
  • physical memory is backed by a bitmap
  • read/write operations strictly forbid page crossing

§Virtual memory (always contiguous):

Frame size = 32 bytes

pos = 0       pos = 64       pos = 96
+------------+------------+------------+
| segment 0  | segment 1  | segment 2  |
+------------+------------+------------+

§Physical frames

[.##...........#...........##.........]
  ^             ^             ^
  S0            S1            S2

Virtual memory remains contiguous even when physical memory is fragmented.

§In case of a memory leak

(missing IdEntry, corrupted entry, or incomplete segment)

Virtual memory → always clean

[#..#.................................]
 ^  ^
S0  S2

Physical memory → leak remains locked/unusable

[.##...........#...........##.........]
  ^             ^             ^
 S0            S1            S2

§Quarantine state

[#....................................]
 ^
&S1    ← quarantined segment (failed free)

You can inspect the state using empty_quarantine() You can clean quarantined blocks using purge()

Structs§

Allocator
Allocator
VirtualAddr
VirtualAddr is the virtual pointer for an IdEntry In the case which the Process has many IdEntry, attribut pos is align with the others parts

Enums§

AllocResult
DesallocResult
IoStatus