Contur 2
Educational OS kernel simulator
Loading...
Searching...
No Matches
contur::IScheduler Class Referenceabstract

Scheduler abstraction managing process state queues. More...

#include <i_scheduler.h>

Inheritance diagram for contur::IScheduler:

Public Member Functions

virtual ~IScheduler ()=default
virtual Result< void > enqueue (PCB &pcb, Tick currentTick)=0
 Enqueues a process into the ready queue.
virtual Result< void > dequeue (ProcessId pid)=0
 Removes a process from scheduler ownership/queues.
virtual Result< ProcessIdselectNext (const IClock &clock)=0
 Selects the process to run next.
virtual Result< void > blockRunning (Tick currentTick)=0
 Moves current running process to blocked queue.
virtual Result< void > blockProcess (ProcessId pid, Tick currentTick)=0
 Moves a specific running or ready process to the blocked queue.
virtual Result< void > unblock (ProcessId pid, Tick currentTick)=0
 Moves a blocked process back to ready queue.
virtual Result< void > terminate (ProcessId pid, Tick currentTick)=0
 Marks process as terminated and removes it from active queues.
virtual std::vector< ProcessIdgetQueueSnapshot () const =0
 Returns ready queue PID snapshot.
virtual std::vector< ProcessIdgetBlockedSnapshot () const =0
 Returns blocked queue PID snapshot.
virtual Result< void > configureLanes (std::size_t laneCount)=0
 Configures scheduler lane count used for per-core ready queues.
virtual std::size_t laneCount () const noexcept=0
 Returns number of configured scheduler lanes.
virtual Result< void > enqueueToLane (PCB &pcb, std::size_t laneIndex, Tick currentTick)=0
 Enqueues process into a specific ready lane.
virtual Result< ProcessIdselectNextForLane (std::size_t laneIndex, const IClock &clock)=0
 Selects/runs next process on a specific lane.
virtual Result< ProcessIdstealNextForLane (std::size_t thiefLane, const IClock &clock)=0
 Steals one ready process from another lane and schedules it on thief lane.
virtual std::vector< std::vector< ProcessId > > getPerLaneQueueSnapshot () const =0
 Returns per-lane ready queue snapshots.
virtual std::vector< ProcessIdrunningProcesses () const =0
 Returns currently running process IDs across scheduler lanes.
virtual Result< void > setPolicy (std::unique_ptr< ISchedulingPolicy > policy)=0
 Replaces scheduling policy at runtime.
virtual std::string_view policyName () const noexcept=0
 Returns active policy name or "Unconfigured".

Detailed Description

Scheduler abstraction managing process state queues.

Coordinates ready/blocked/running process sets and delegates process ordering decisions to the active ISchedulingPolicy implementation.

Definition at line 23 of file i_scheduler.h.

Constructor & Destructor Documentation

◆ ~IScheduler()

virtual contur::IScheduler::~IScheduler ( )
virtualdefault

Member Function Documentation

◆ blockProcess()

virtual Result< void > contur::IScheduler::blockProcess ( ProcessId pid,
Tick currentTick )
nodiscardpure virtual

Moves a specific running or ready process to the blocked queue.

Parameters
pidProcess identifier to block.
currentTickSimulation tick for timing metadata.
Returns
Ok on success; NotFound if pid is unknown; InvalidState on bad transition.

Implemented in contur::Scheduler.

◆ blockRunning()

virtual Result< void > contur::IScheduler::blockRunning ( Tick currentTick)
nodiscardpure virtual

Moves current running process to blocked queue.

Parameters
currentTickSimulation tick for blocked queue timing metadata.
Returns
Ok on success; error if no process is currently running.
Note
In multi-lane deployments prefer blockProcess(pid, tick) to avoid ambiguity when several lanes have a running process simultaneously.

Implemented in contur::Scheduler.

◆ configureLanes()

virtual Result< void > contur::IScheduler::configureLanes ( std::size_t laneCount)
nodiscardpure virtual

Configures scheduler lane count used for per-core ready queues.

Parameters
laneCountNumber of scheduler lanes (must be >= 1).
Returns
Ok on success; InvalidArgument for zero; InvalidState if scheduler is not empty.

Implemented in contur::Scheduler.

References laneCount().

◆ dequeue()

virtual Result< void > contur::IScheduler::dequeue ( ProcessId pid)
nodiscardpure virtual

Removes a process from scheduler ownership/queues.

Parameters
pidIdentifier of the process to remove.
Returns
Ok on success; error if pid is unknown.

Implemented in contur::Scheduler.

◆ enqueue()

virtual Result< void > contur::IScheduler::enqueue ( PCB & pcb,
Tick currentTick )
nodiscardpure virtual

Enqueues a process into the ready queue.

Parameters
pcbProcess control block to add.
currentTickSimulation tick used for queue timing metadata.
Returns
Ok on success; error if enqueueing is invalid for current state.

Implemented in contur::Scheduler.

◆ enqueueToLane()

virtual Result< void > contur::IScheduler::enqueueToLane ( PCB & pcb,
std::size_t laneIndex,
Tick currentTick )
nodiscardpure virtual

Enqueues process into a specific ready lane.

Parameters
pcbProcess control block to add.
laneIndexTarget lane index.
currentTickSimulation tick used for queue timing metadata.
Returns
Ok on success; InvalidArgument for bad lane/pid; InvalidState for invalid transition.

Implemented in contur::Scheduler.

References enqueueToLane().

Referenced by enqueueToLane().

◆ getBlockedSnapshot()

virtual std::vector< ProcessId > contur::IScheduler::getBlockedSnapshot ( ) const
nodiscardpure virtual

Returns blocked queue PID snapshot.

Returns
Ordered list of process identifiers currently in the blocked queue.

Implemented in contur::Scheduler.

◆ getPerLaneQueueSnapshot()

virtual std::vector< std::vector< ProcessId > > contur::IScheduler::getPerLaneQueueSnapshot ( ) const
nodiscardpure virtual

Returns per-lane ready queue snapshots.

Returns
One ready queue snapshot per lane.

Implemented in contur::Scheduler.

References getPerLaneQueueSnapshot().

Referenced by getPerLaneQueueSnapshot().

◆ getQueueSnapshot()

virtual std::vector< ProcessId > contur::IScheduler::getQueueSnapshot ( ) const
nodiscardpure virtual

Returns ready queue PID snapshot.

Returns
Ordered list of process identifiers currently in the ready queue.

Implemented in contur::Scheduler.

◆ laneCount()

virtual std::size_t contur::IScheduler::laneCount ( ) const
nodiscardpure virtualnoexcept

Returns number of configured scheduler lanes.

Implemented in contur::Scheduler.

Referenced by configureLanes().

◆ policyName()

virtual std::string_view contur::IScheduler::policyName ( ) const
nodiscardpure virtualnoexcept

Returns active policy name or "Unconfigured".

Implemented in contur::Scheduler.

References policyName().

Referenced by policyName().

◆ runningProcesses()

virtual std::vector< ProcessId > contur::IScheduler::runningProcesses ( ) const
nodiscardpure virtual

Returns currently running process IDs across scheduler lanes.

Returns
Running process identifiers; empty when all lanes are idle.

Implemented in contur::Scheduler.

References runningProcesses().

Referenced by runningProcesses().

◆ selectNext()

virtual Result< ProcessId > contur::IScheduler::selectNext ( const IClock & clock)
nodiscardpure virtual

Selects the process to run next.

Parameters
clockSimulation clock for time-aware policy decisions.
Returns
Selected process identifier, or error if no runnable process exists.

Implemented in contur::Scheduler.

◆ selectNextForLane()

virtual Result< ProcessId > contur::IScheduler::selectNextForLane ( std::size_t laneIndex,
const IClock & clock )
nodiscardpure virtual

Selects/runs next process on a specific lane.

Parameters
laneIndexTarget lane index.
clockSimulation clock for policy decisions.
Returns
Selected process id, or NotFound/InvalidState.

Implemented in contur::Scheduler.

References selectNextForLane().

Referenced by selectNextForLane().

◆ setPolicy()

virtual Result< void > contur::IScheduler::setPolicy ( std::unique_ptr< ISchedulingPolicy > policy)
nodiscardpure virtual

Replaces scheduling policy at runtime.

Parameters
policyNew scheduling policy instance.
Returns
Ok on success; InvalidState if policy is null.

Implemented in contur::Scheduler.

References setPolicy().

Referenced by setPolicy().

◆ stealNextForLane()

virtual Result< ProcessId > contur::IScheduler::stealNextForLane ( std::size_t thiefLane,
const IClock & clock )
nodiscardpure virtual

Steals one ready process from another lane and schedules it on thief lane.

This is scheduler-level (intra-dispatcher) work stealing: it moves a simulated process between per-core ready queues inside a single dispatcher. It is independent of runtime-level (inter-dispatcher) work stealing performed by DispatcherPool, which moves whole dispatcher lanes between host threads.

Parameters
thiefLaneLane that steals work.
clockSimulation clock for selection and preemption checks.
Returns
Selected process id on thief lane, or NotFound/InvalidState.

Implemented in contur::Scheduler.

References stealNextForLane().

Referenced by stealNextForLane().

◆ terminate()

virtual Result< void > contur::IScheduler::terminate ( ProcessId pid,
Tick currentTick )
nodiscardpure virtual

Marks process as terminated and removes it from active queues.

Parameters
pidIdentifier of the process to terminate.
currentTickSimulation tick used for final accounting.
Returns
Ok on success; error if pid is unknown.

Implemented in contur::Scheduler.

◆ unblock()

virtual Result< void > contur::IScheduler::unblock ( ProcessId pid,
Tick currentTick )
nodiscardpure virtual

Moves a blocked process back to ready queue.

Parameters
pidIdentifier of the blocked process.
currentTickSimulation tick used when re-enqueueing.
Returns
Ok on success; error if pid is not blocked.

Implemented in contur::Scheduler.


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