contur2
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 > 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 ProcessId runningProcess () const noexcept=0
 Returns currently running process, or INVALID_PID.
virtual Result< void > setPolicy (std::unique_ptr< ISchedulingPolicy > policy)=0
 Replaces scheduling policy at runtime.

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 22 of file i_scheduler.h.

Constructor & Destructor Documentation

◆ ~IScheduler()

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

Member Function Documentation

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

Implemented in contur::Scheduler.

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

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

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

◆ runningProcess()

virtual ProcessId contur::IScheduler::runningProcess ( ) const
nodiscardpure virtualnoexcept

Returns currently running process, or INVALID_PID.

Returns
Running process identifier, or INVALID_PID if CPU is idle.

Implemented in contur::Scheduler.

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

◆ 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; error if policy is null or unsupported.

Implemented in contur::Scheduler.

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