MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / num_levels_needed

Function num_levels_needed

kernel/src/memory/frame_allocator.rs:42–51  ·  view source on GitHub ↗

Calculate the number of bitmap levels needed Bitmaps are in chunks of 32, so each level multiplies the maximum number of frames by 32.

(num_frames: u64)

Source from the content-addressed store, hash-verified

40/// Bitmaps are in chunks of 32, so each level multiplies the maximum
41/// number of frames by 32.
42fn num_levels_needed(num_frames: u64) -> usize {
43 let mut max_frames = 32;
44 let mut levels = 1;
45
46 while num_frames > max_frames {
47 levels += 1;
48 max_frames *= 32;
49 }
50 levels
51}
52
53#[test_case]
54fn test_num_levels_needed() {

Callers 1

initMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected