Struct vm_memory::bitmap::AtomicBitmap
source · pub struct AtomicBitmap { /* private fields */ }
Expand description
AtomicBitmap
implements a simple bit map on the page level with test and set operations.
It is page-size aware, so it converts addresses to page numbers before setting or clearing
the bits.
Implementations§
source§impl AtomicBitmap
impl AtomicBitmap
sourcepub fn new(byte_size: usize, page_size: NonZeroUsize) -> Self
pub fn new(byte_size: usize, page_size: NonZeroUsize) -> Self
Create a new bitmap of byte_size
, with one bit per page. This is effectively
rounded up, and we get a new vector of the next multiple of 64 bigger than bit_size
.
sourcepub fn is_bit_set(&self, index: usize) -> bool
pub fn is_bit_set(&self, index: usize) -> bool
Is bit n
set? Bits outside the range of the bitmap are always unset.
sourcepub fn is_addr_set(&self, addr: usize) -> bool
pub fn is_addr_set(&self, addr: usize) -> bool
Is the bit corresponding to address addr
set?
sourcepub fn set_addr_range(&self, start_addr: usize, len: usize)
pub fn set_addr_range(&self, start_addr: usize, len: usize)
Set a range of len
bytes starting at start_addr
. The first bit set in the bitmap
is for the page corresponding to start_addr
, and the last bit that we set corresponds
to address start_addr + len - 1
.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the length of the bitmap in bits (i.e. in how many pages it can represent).
sourcepub fn get_and_reset(&self) -> Vec<u64>
pub fn get_and_reset(&self) -> Vec<u64>
Atomically get and reset the dirty page bitmap.