![]() |
Contur 2
Educational OS kernel simulator
|
Abstract interface for virtual memory management. More...
#include <i_virtual_memory.h>
Public Member Functions | |
| virtual | ~IVirtualMemory ()=default |
| virtual Result< MemoryAddress > | allocateSlot (ProcessId processId, std::size_t size)=0 |
| Allocates a virtual memory slot for a process. | |
| virtual Result< void > | freeSlot (ProcessId processId)=0 |
| Frees a previously allocated slot. | |
| virtual Result< void > | loadSegment (ProcessId processId, const std::vector< Block > &data)=0 |
| Loads a code/data segment into a process's virtual address space. | |
| virtual Result< std::vector< Block > > | readSegment (ProcessId processId) const =0 |
| Reads the entire code/data segment from a process's virtual memory. | |
| virtual std::size_t | totalSlots () const noexcept=0 |
| Returns the number of total slots available. | |
| virtual std::size_t | freeSlots () const noexcept=0 |
| Returns the number of free (unallocated) slots. | |
| virtual bool | hasSlot (ProcessId processId) const noexcept=0 |
| Checks whether a process has an allocated slot. | |
| virtual std::size_t | slotSize (ProcessId processId) const noexcept=0 |
| Returns the slot size (number of blocks) for a process, or 0 if no slot. | |
Abstract interface for virtual memory management.
Provides slot-based allocation of virtual address spaces for processes. Each slot represents a contiguous virtual memory region that can be loaded with a code/data segment (vector of Blocks).
VirtualMemory sits conceptually above the MMU — it manages which processes have virtual address spaces and provides bulk load/store operations, while the MMU handles per-address translation.
Definition at line 25 of file i_virtual_memory.h.
|
virtualdefault |
|
nodiscardpure virtual |
Allocates a virtual memory slot for a process.
| processId | The owning process. |
| size | Number of Block cells in the virtual address range. |
Implemented in contur::VirtualMemory.
|
nodiscardpure virtual |
Frees a previously allocated slot.
| processId | The owning process. |
Implemented in contur::VirtualMemory.
|
nodiscardpure virtualnoexcept |
Returns the number of free (unallocated) slots.
Implemented in contur::VirtualMemory.
References freeSlots().
Referenced by freeSlots().
|
nodiscardpure virtualnoexcept |
Checks whether a process has an allocated slot.
Implemented in contur::VirtualMemory.
References hasSlot().
Referenced by hasSlot().
|
nodiscardpure virtual |
Loads a code/data segment into a process's virtual address space.
| processId | The owning process. |
| data | The blocks to load. |
Implemented in contur::VirtualMemory.
|
nodiscardpure virtual |
Reads the entire code/data segment from a process's virtual memory.
| processId | The owning process. |
Implemented in contur::VirtualMemory.
|
nodiscardpure virtualnoexcept |
Returns the slot size (number of blocks) for a process, or 0 if no slot.
Implemented in contur::VirtualMemory.
References slotSize().
Referenced by slotSize().
|
nodiscardpure virtualnoexcept |
Returns the number of total slots available.
Implemented in contur::VirtualMemory.