Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
contur::ProcessImage Class Reference

Full in-memory representation of a process. More...

#include <process_image.h>

Public Member Functions

 ProcessImage (ProcessId id, std::string name, std::vector< Block > code, Priority priority=Priority{}, Tick arrivalTime=0)
 Constructs a ProcessImage with the given parameters.
 ~ProcessImage ()
 Destroys process image.
 ProcessImage (const ProcessImage &)=delete
ProcessImageoperator= (const ProcessImage &)=delete
 ProcessImage (ProcessImage &&) noexcept
 Move-constructs process image state.
ProcessImageoperator= (ProcessImage &&) noexcept
 Move-assigns process image state.
const PCBpcb () const noexcept
 Returns a const reference to the PCB.
PCBpcb () noexcept
 Returns a mutable reference to the PCB.
const RegisterFileregisters () const noexcept
 Returns a const reference to the register file.
RegisterFileregisters () noexcept
 Returns a mutable reference to the register file.
const std::vector< Block > & code () const noexcept
 Returns a const reference to the code segment.
std::size_t codeSize () const noexcept
 Returns the size of the code segment (number of Blocks).
const BlockreadCode (std::size_t offset) const
 Reads a single Block from the code segment.
void setCode (std::vector< Block > newCode)
 Replaces the code segment with new code.
std::string_view nativePath () const noexcept
 Returns the path to the native host executable backing this process, or an empty view when the process is interpreter-backed.
void setNativePath (std::string path)
 Sets the native executable path.
ProcessId id () const noexcept
 Returns the process ID.
std::string_view name () const noexcept
 Returns the process name.
ProcessState state () const noexcept
 Returns the current process state.
const Prioritypriority () const noexcept
 Returns the process priority.

Private Attributes

std::unique_ptr< Impl > impl_

Detailed Description

Full in-memory representation of a process.

Contains all data needed to execute a process:

  • PCB for lifecycle management
  • Code segment (vector<Block>) for the interpreter
  • RegisterFile for CPU context save/restore

Ownership: ProcessImage owns all three components.

Definition at line 35 of file process_image.h.

Constructor & Destructor Documentation

◆ ProcessImage() [1/3]

contur::ProcessImage::ProcessImage ( ProcessId id,
std::string name,
std::vector< Block > code,
Priority priority = Priority{},
Tick arrivalTime = 0 )

Constructs a ProcessImage with the given parameters.

Parameters
idUnique process identifier.
nameHuman-readable process name.
codeThe program code (vector of Blocks).
priorityProcess priority (defaults to Normal).
arrivalTimeSimulation tick at creation.

References code(), name(), and priority().

Referenced by operator=(), operator=(), ProcessImage(), and ProcessImage().

◆ ~ProcessImage()

contur::ProcessImage::~ProcessImage ( )

Destroys process image.

◆ ProcessImage() [2/3]

contur::ProcessImage::ProcessImage ( const ProcessImage & )
delete

References ProcessImage().

◆ ProcessImage() [3/3]

contur::ProcessImage::ProcessImage ( ProcessImage && )
noexcept

Move-constructs process image state.

References ProcessImage().

Member Function Documentation

◆ code()

const std::vector< Block > & contur::ProcessImage::code ( ) const
nodiscardnoexcept

Returns a const reference to the code segment.

References code().

Referenced by code(), and ProcessImage().

◆ codeSize()

std::size_t contur::ProcessImage::codeSize ( ) const
nodiscardnoexcept

Returns the size of the code segment (number of Blocks).

References codeSize().

Referenced by codeSize().

◆ id()

ProcessId contur::ProcessImage::id ( ) const
nodiscardnoexcept

Returns the process ID.

◆ name()

std::string_view contur::ProcessImage::name ( ) const
nodiscardnoexcept

Returns the process name.

References name().

Referenced by name(), and ProcessImage().

◆ nativePath()

std::string_view contur::ProcessImage::nativePath ( ) const
nodiscardnoexcept

Returns the path to the native host executable backing this process, or an empty view when the process is interpreter-backed.

Only consulted by NativeEngine. Interpreter-backed processes leave this empty.

References nativePath().

Referenced by nativePath().

◆ operator=() [1/2]

ProcessImage & contur::ProcessImage::operator= ( const ProcessImage & )
delete

References ProcessImage().

◆ operator=() [2/2]

ProcessImage & contur::ProcessImage::operator= ( ProcessImage && )
noexcept

Move-assigns process image state.

References ProcessImage().

◆ pcb() [1/2]

const PCB & contur::ProcessImage::pcb ( ) const
nodiscardnoexcept

Returns a const reference to the PCB.

References pcb().

Referenced by pcb(), and pcb().

◆ pcb() [2/2]

PCB & contur::ProcessImage::pcb ( )
nodiscardnoexcept

Returns a mutable reference to the PCB.

References pcb().

◆ priority()

const Priority & contur::ProcessImage::priority ( ) const
nodiscardnoexcept

Returns the process priority.

References priority().

Referenced by priority(), and ProcessImage().

◆ readCode()

const Block & contur::ProcessImage::readCode ( std::size_t offset) const
nodiscard

Reads a single Block from the code segment.

Parameters
offsetIndex into the code segment.
Returns
The Block at the given offset.
Precondition
offset < codeSize()

References readCode().

Referenced by readCode().

◆ registers() [1/2]

const RegisterFile & contur::ProcessImage::registers ( ) const
nodiscardnoexcept

Returns a const reference to the register file.

References registers().

Referenced by registers(), and registers().

◆ registers() [2/2]

RegisterFile & contur::ProcessImage::registers ( )
nodiscardnoexcept

Returns a mutable reference to the register file.

References registers().

◆ setCode()

void contur::ProcessImage::setCode ( std::vector< Block > newCode)

Replaces the code segment with new code.

Parameters
newCodeThe replacement program.

References setCode().

Referenced by setCode().

◆ setNativePath()

void contur::ProcessImage::setNativePath ( std::string path)

Sets the native executable path.

Parameters
pathFilesystem path to a host-OS executable. Empty clears the path.

References setNativePath().

Referenced by setNativePath().

◆ state()

ProcessState contur::ProcessImage::state ( ) const
nodiscardnoexcept

Returns the current process state.

References state().

Referenced by state().

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> contur::ProcessImage::impl_
private

Definition at line 118 of file process_image.h.


The documentation for this class was generated from the following file: