Contur 2
Educational OS kernel simulator
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 ()
 Destroys process control block.
 PCB (const PCB &)=delete
PCBoperator= (const PCB &)=delete
 PCB (PCB &&) noexcept
 Move-constructs PCB state.
PCBoperator= (PCB &&) noexcept
 Move-assigns PCB state.
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.

References name(), and priority().

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

◆ ~PCB()

contur::PCB::~PCB ( )

Destroys process control block.

◆ PCB() [2/3]

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

References PCB().

◆ PCB() [3/3]

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

Move-constructs PCB state.

References PCB().

Member Function Documentation

◆ addBlockedTime()

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

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

References addBlockedTime().

Referenced by addBlockedTime().

◆ addCpuTime()

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

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

References addCpuTime().

Referenced by addCpuTime().

◆ addressInfo() [1/2]

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

Returns a const reference to the address mapping info.

References addressInfo().

Referenced by addressInfo(), and addressInfo().

◆ addressInfo() [2/2]

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

Returns a mutable reference to the address mapping info.

References addressInfo().

◆ addWaitTime()

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

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

References addWaitTime().

Referenced by addWaitTime().

◆ 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.

References name().

Referenced by name(), and PCB().

◆ operator=() [1/2]

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

References PCB().

◆ operator=() [2/2]

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

Move-assigns PCB state.

References PCB().

◆ priority()

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

Returns a const reference to the process priority.

References priority().

Referenced by PCB(), priority(), and setPriority().

◆ setEffectivePriority()

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

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

References setEffectivePriority().

Referenced by setEffectivePriority().

◆ setNice()

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

Sets the nice value (clamped to valid range).

References setNice().

Referenced by setNice().

◆ setPriority()

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

Sets the full priority descriptor.

References priority(), and setPriority().

Referenced by setPriority().

◆ 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.

References setState().

Referenced by setState().

◆ state()

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

Returns the current process state.

References state().

Referenced by state().

◆ timing() [1/2]

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

Returns a const reference to the process timing data.

References timing().

Referenced by timing(), and timing().

◆ timing() [2/2]

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

Returns a mutable reference to the timing data.

References timing().

Member Data Documentation

◆ impl_

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

Definition at line 128 of file pcb.h.


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