[][src]Function region::lock

pub fn lock(address: *const u8, size: usize) -> Result<LockGuard>

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.

  • The range is [address, address + size)
  • The address may not be null.
  • 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.

Examples

let data = [0; 100];
let _guard = region::lock(data.as_ptr(), data.len()).unwrap();