![]() |
Contur 2
Educational OS kernel simulator
|
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 | |
| PCB & | operator= (const PCB &)=delete |
| PCB (PCB &&) noexcept | |
| Move-constructs PCB state. | |
| PCB & | operator= (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 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 | ( | ProcessId | id, |
| std::string | name, | ||
| Priority | priority = Priority{}, | ||
| Tick | arrivalTime = 0 ) |
Constructs a PCB with the given ID, name, and optional priority.
| id | Unique process identifier (must not be INVALID_PID). |
| name | Human-readable process name. |
| priority | Initial priority descriptor (defaults to Normal). |
| arrivalTime | Simulation tick when the process was created. |
References name(), and priority().
Referenced by operator=(), operator=(), PCB(), and PCB().
| contur::PCB::~PCB | ( | ) |
Destroys process control block.
|
delete |
References PCB().
| void contur::PCB::addBlockedTime | ( | Tick | ticks | ) |
Adds the given number of ticks to the total blocked time.
References addBlockedTime().
Referenced by addBlockedTime().
| void contur::PCB::addCpuTime | ( | Tick | ticks | ) |
Adds the given number of ticks to the total CPU time.
References addCpuTime().
Referenced by addCpuTime().
|
nodiscardnoexcept |
Returns a const reference to the address mapping info.
References addressInfo().
Referenced by addressInfo(), and addressInfo().
|
nodiscardnoexcept |
Returns a mutable reference to the address mapping info.
References addressInfo().
| void contur::PCB::addWaitTime | ( | Tick | ticks | ) |
Adds the given number of ticks to the total wait time.
References addWaitTime().
Referenced by addWaitTime().
|
nodiscardnoexcept |
Returns the unique process ID.
|
nodiscardnoexcept |
|
nodiscardnoexcept |
Returns a const reference to the process priority.
References priority().
Referenced by PCB(), priority(), and setPriority().
| void contur::PCB::setEffectivePriority | ( | PriorityLevel | level | ) |
Sets only the effective priority level (for dynamic scheduling).
References setEffectivePriority().
Referenced by setEffectivePriority().
| void contur::PCB::setNice | ( | std::int32_t | nice | ) |
| void contur::PCB::setPriority | ( | const Priority & | priority | ) |
Sets the full priority descriptor.
References priority(), and setPriority().
Referenced by setPriority().
|
nodiscard |
Transitions the process to a new state.
| newState | The target state. |
| currentTick | The simulation tick at which the transition occurs. |
References setState().
Referenced by setState().
|
nodiscardnoexcept |
|
nodiscardnoexcept |
|
nodiscardnoexcept |
Returns a mutable reference to the timing data.
References timing().