contur2
Loading...
Searching...
No Matches

Process Control Block — stores all metadata for a single process. More...

#include <pcb.h>

Public Member Functions

 PCB (ProcessId id, std::string name, Priority priority=Priority{}, Tick arrivalTime=0)
 Constructs a PCB with the given ID, name, and optional priority.
 ~PCB ()
 PCB (const PCB &)=delete
PCBoperator= (const PCB &)=delete
 PCB (PCB &&) noexcept
PCBoperator= (PCB &&) noexcept
ProcessId id () const noexcept
 Returns the unique process ID.
std::string_view name () const noexcept
 Returns the human-readable process name.
ProcessState state () const noexcept
 Returns the current process state.
bool setState (ProcessState newState, Tick currentTick=0)
 Transitions the process to a new state.
const Prioritypriority () const noexcept
 Returns a const reference to the process priority.
void setPriority (const Priority &priority)
 Sets the full priority descriptor.
void setEffectivePriority (PriorityLevel level)
 Sets only the effective priority level (for dynamic scheduling).
void setNice (std::int32_t nice)
 Sets the nice value (clamped to valid range).
const ProcessTimingtiming () const noexcept
 Returns a const reference to the process timing data.
ProcessTimingtiming () noexcept
 Returns a mutable reference to the timing data.
void addCpuTime (Tick ticks)
 Adds the given number of ticks to the total CPU time.
void addWaitTime (Tick ticks)
 Adds the given number of ticks to the total wait time.
void addBlockedTime (Tick ticks)
 Adds the given number of ticks to the total blocked time.
const ProcessAddressInfoaddressInfo () const noexcept
 Returns a const reference to the address mapping info.
ProcessAddressInfoaddressInfo () noexcept
 Returns a mutable reference to the address mapping info.

Private Attributes

std::unique_ptr< Impl > impl_

Detailed Description

Process Control Block — stores all metadata for a single process.

The PCB is a standalone class using composition. It contains process identity, state, priority, timing info, and address mapping — everything the scheduler, dispatcher, and MMU need to manage the process.

Definition at line 54 of file pcb.h.

Constructor & Destructor Documentation

◆ PCB() [1/3]

contur::PCB::PCB ( ProcessId id,
std::string name,
Priority priority = Priority{},
Tick arrivalTime = 0 )

Constructs a PCB with the given ID, name, and optional priority.

Parameters
idUnique process identifier (must not be INVALID_PID).
nameHuman-readable process name.
priorityInitial priority descriptor (defaults to Normal).
arrivalTimeSimulation tick when the process was created.

◆ ~PCB()

contur::PCB::~PCB ( )

◆ PCB() [2/3]

contur::PCB::PCB ( const PCB & )
delete

◆ PCB() [3/3]

contur::PCB::PCB ( PCB && )
noexcept

Member Function Documentation

◆ addBlockedTime()

void contur::PCB::addBlockedTime ( Tick ticks)

Adds the given number of ticks to the total blocked time.

◆ addCpuTime()

void contur::PCB::addCpuTime ( Tick ticks)

Adds the given number of ticks to the total CPU time.

◆ addressInfo() [1/2]

const ProcessAddressInfo & contur::PCB::addressInfo ( ) const
nodiscardnoexcept

Returns a const reference to the address mapping info.

◆ addressInfo() [2/2]

ProcessAddressInfo & contur::PCB::addressInfo ( )
nodiscardnoexcept

Returns a mutable reference to the address mapping info.

◆ addWaitTime()

void contur::PCB::addWaitTime ( Tick ticks)

Adds the given number of ticks to the total wait time.

◆ id()

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

Returns the unique process ID.

◆ name()

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

Returns the human-readable process name.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ priority()

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

Returns a const reference to the process priority.

◆ setEffectivePriority()

void contur::PCB::setEffectivePriority ( PriorityLevel level)

Sets only the effective priority level (for dynamic scheduling).

◆ setNice()

void contur::PCB::setNice ( std::int32_t nice)

Sets the nice value (clamped to valid range).

◆ setPriority()

void contur::PCB::setPriority ( const Priority & priority)

Sets the full priority descriptor.

◆ setState()

bool contur::PCB::setState ( ProcessState newState,
Tick currentTick = 0 )
nodiscard

Transitions the process to a new state.

Parameters
newStateThe target state.
currentTickThe simulation tick at which the transition occurs.
Returns
true if the transition was valid and applied, false otherwise.

◆ state()

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

Returns the current process state.

◆ timing() [1/2]

const ProcessTiming & contur::PCB::timing ( ) const
nodiscardnoexcept

Returns a const reference to the process timing data.

◆ timing() [2/2]

ProcessTiming & contur::PCB::timing ( )
nodiscardnoexcept

Returns a mutable reference to the timing data.

Member Data Documentation

◆ impl_

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

Definition at line 124 of file pcb.h.


The documentation for this class was generated from the following file:
  • include/contur/process/pcb.h