|
contur2
|
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 | |
| PCB & | operator= (const PCB &)=delete |
| PCB (PCB &&) noexcept | |
| PCB & | operator= (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 Priority & | priority () 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 ProcessTiming & | timing () const noexcept |
| Returns a const reference to the process timing data. | |
| ProcessTiming & | timing () 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 ProcessAddressInfo & | addressInfo () const noexcept |
| Returns a const reference to the address mapping info. | |
| ProcessAddressInfo & | addressInfo () noexcept |
| Returns a mutable reference to the address mapping info. | |
Private Attributes | |
| std::unique_ptr< Impl > | impl_ |
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.
| contur::PCB::~PCB | ( | ) |
|
delete |
|
noexcept |
| void contur::PCB::addBlockedTime | ( | Tick | ticks | ) |
Adds the given number of ticks to the total blocked time.
| void contur::PCB::addCpuTime | ( | Tick | ticks | ) |
Adds the given number of ticks to the total CPU time.
|
nodiscardnoexcept |
Returns a const reference to the address mapping info.
|
nodiscardnoexcept |
Returns a mutable reference to the address mapping info.
| void contur::PCB::addWaitTime | ( | Tick | ticks | ) |
Adds the given number of ticks to the total wait time.
|
nodiscardnoexcept |
Returns the unique process ID.
|
nodiscardnoexcept |
Returns the human-readable process name.
|
nodiscardnoexcept |
Returns a const reference to the process priority.
| void contur::PCB::setEffectivePriority | ( | PriorityLevel | level | ) |
Sets only the effective priority level (for dynamic scheduling).
| void contur::PCB::setNice | ( | std::int32_t | nice | ) |
Sets the nice value (clamped to valid range).
| void contur::PCB::setPriority | ( | const Priority & | priority | ) |
Sets the full priority descriptor.
|
nodiscard |
Transitions the process to a new state.
| newState | The target state. |
| currentTick | The simulation tick at which the transition occurs. |
|
nodiscardnoexcept |
Returns the current process state.
|
nodiscardnoexcept |
Returns a const reference to the process timing data.
|
nodiscardnoexcept |
Returns a mutable reference to the timing data.