Module vm_memory::volatile_memory

source ·
Expand description

Types for volatile access to memory.

Two of the core rules for safe rust is no data races and no aliased mutable references. VolatileRef and VolatileSlice, along with types that produce those which implement VolatileMemory, allow us to sidestep that rule by wrapping pointers that absolutely have to be accessed volatile. Some systems really do need to operate on shared memory and can’t have the compiler reordering or eliding access because it has no visibility into what other systems are doing with that hunk of memory.

For the purposes of maintaining safety, volatile memory has some rules of its own:

  1. No references or slices to volatile memory (& or &mut).
  2. Access should always been done with a volatile read or write. The First rule is because having references of any kind to memory considered volatile would violate pointer aliasing. The second is because unvolatile accesses are inherently undefined if done concurrently without synchronization. With volatile access we know that the compiler has not reordered or elided the access.

Structs§

  • A memory location that supports volatile access to an array of elements of type T.
  • A memory location that supports volatile access to an instance of T.
  • A slice of raw memory that supports volatile access.

Enums§

  • VolatileMemory related errors.

Traits§

Functions§

Type Aliases§

  • Result of volatile memory operations.