Expand description
Locks one or more memory regions to RAM.
The memory pages within the address range is guaranteed to stay in RAM
except for specials cases, such as hibernation and memory starvation. It
returns a LockGuard
, which unlock
s the affected regions once
dropped.
Parameters
- The range is
[address, address + size)
- The address is rounded down to the closest page boundary.
- The size may not be zero.
- The size is rounded up to the closest page boundary, relative to the address.
Errors
- If an interaction with the underlying operating system fails, an error will be returned.
- If size is zero,
Error::InvalidParameter
will be returned.
Examples
let data = [0; 100];
let _guard = region::lock(data.as_ptr(), data.len())?;