nsbaci 1.0
Loading...
Searching...
No Matches
nsbaci::services::runtime::NsbaciScheduler Class Referencefinal

BACI-specific implementation of the Scheduler. More...

#include <nsbaciScheduler.h>

Inheritance diagram for nsbaci::services::runtime::NsbaciScheduler:
Collaboration diagram for nsbaci::services::runtime::NsbaciScheduler:

Public Member Functions

ThreadpickNext () override
 Pick the next thread to run.
void addThread (Thread thread) override
 Add a new thread to the scheduler.
void blockCurrent () override
 Block the currently running thread.
void blockOnSemaphore (uint32_t semaphoreAddr) override
 Block current thread on a semaphore.
size_t unblockSemaphore (uint32_t semaphoreAddr) override
 Unblock threads waiting on a semaphore.
void unblock (nsbaci::types::ThreadID threadId) override
 Move a thread from blocked to ready state.
void yield () override
 Yield the current thread (move to back of ready queue).
void terminateCurrent () override
 Terminate the currently running thread.
bool hasThreads () const override
 Check if there are any threads left to run.
Threadcurrent () override
 Get the currently running thread.
void clear () override
 Clear all threads and reset scheduler state.
void unblockIO () override
 Move all I/O waiting threads back to ready queue.
const std::vector< Thread > & getThreads () const override
 Get all threads managed by the scheduler.
void blockOnCoend (int32_t expectedThreads) override
 Block current thread on coend (waiting for spawned threads).
void checkCoendUnblock () override
 Check if coend-blocked threads should be unblocked.

Additional Inherited Members

Protected Attributes inherited from nsbaci::services::runtime::Scheduler
std::vector< Threadthreads
 All threads owned by scheduler.
std::vector< size_t > readyQueue
 Indices of ready threads.
std::vector< size_t > blockedQueue
 Indices of blocked threads.
std::vector< size_t > ioQueue
 Indices of I/O waiting threads.
std::optional< size_t > runningIndex
 Index of currently running thread.
std::unordered_map< uint32_t, std::vector< size_t > > semaphoreQueues
 Map from semaphore address to list of waiting thread indices.
std::vector< std::pair< size_t, int32_t > > coendQueue
 Threads waiting at coend, with their expected thread counts.

Detailed Description

BACI-specific implementation of the Scheduler.

NsbaciScheduler implements a round-robin scheduling algorithm with support for blocked, ready, running, and I/O waiting states. Threads are selected randomly from the ready queue to simulate non-deterministic concurrent execution.

Member Function Documentation

◆ addThread()

void nsbaci::services::runtime::NsbaciScheduler::addThread ( Thread thread)
overridevirtual

Add a new thread to the scheduler.

Parameters
threadThe thread to add.

Implements nsbaci::services::runtime::Scheduler.

Here is the call graph for this function:

◆ blockCurrent()

void nsbaci::services::runtime::NsbaciScheduler::blockCurrent ( )
overridevirtual

Block the currently running thread.

Implements nsbaci::services::runtime::Scheduler.

Here is the call graph for this function:

◆ blockOnCoend()

void nsbaci::services::runtime::NsbaciScheduler::blockOnCoend ( int32_t expectedThreads)
overridevirtual

Block current thread on coend (waiting for spawned threads).

Parameters
expectedThreadsNumber of threads that should terminate.

Implements nsbaci::services::runtime::Scheduler.

Here is the call graph for this function:

◆ blockOnSemaphore()

void nsbaci::services::runtime::NsbaciScheduler::blockOnSemaphore ( uint32_t semaphoreAddr)
overridevirtual

Block current thread on a semaphore.

Parameters
semaphoreAddrThe address of the semaphore.

Implements nsbaci::services::runtime::Scheduler.

Here is the call graph for this function:

◆ checkCoendUnblock()

void nsbaci::services::runtime::NsbaciScheduler::checkCoendUnblock ( )
overridevirtual

Check if coend-blocked threads should be unblocked.

Called after a thread terminates.

Implements nsbaci::services::runtime::Scheduler.

Here is the caller graph for this function:

◆ clear()

void nsbaci::services::runtime::NsbaciScheduler::clear ( )
overridevirtual

Clear all threads and reset scheduler state.

Implements nsbaci::services::runtime::Scheduler.

◆ current()

Thread * nsbaci::services::runtime::NsbaciScheduler::current ( )
overridevirtual

Get the currently running thread.

Returns
Pointer to current thread, or nullptr if none.

Implements nsbaci::services::runtime::Scheduler.

Here is the caller graph for this function:

◆ getThreads()

const std::vector< Thread > & nsbaci::services::runtime::NsbaciScheduler::getThreads ( ) const
overridevirtual

Get all threads managed by the scheduler.

Returns
Const reference to the threads vector.

Implements nsbaci::services::runtime::Scheduler.

◆ hasThreads()

bool nsbaci::services::runtime::NsbaciScheduler::hasThreads ( ) const
overridevirtual

Check if there are any threads left to run.

Returns
True if there are threads in any queue.

Implements nsbaci::services::runtime::Scheduler.

◆ pickNext()

Thread * nsbaci::services::runtime::NsbaciScheduler::pickNext ( )
overridevirtual

Pick the next thread to run.

Returns
Pointer to the next thread, or nullptr if no threads are ready.

Implements nsbaci::services::runtime::Scheduler.

Here is the call graph for this function:

◆ terminateCurrent()

void nsbaci::services::runtime::NsbaciScheduler::terminateCurrent ( )
overridevirtual

Terminate the currently running thread.

Implements nsbaci::services::runtime::Scheduler.

Here is the call graph for this function:

◆ unblock()

void nsbaci::services::runtime::NsbaciScheduler::unblock ( nsbaci::types::ThreadID threadId)
overridevirtual

Move a thread from blocked to ready state.

Parameters
threadIdThe ID of the thread to unblock.

Implements nsbaci::services::runtime::Scheduler.

◆ unblockIO()

void nsbaci::services::runtime::NsbaciScheduler::unblockIO ( )
overridevirtual

Move all I/O waiting threads back to ready queue.

Called when input becomes available.

Implements nsbaci::services::runtime::Scheduler.

◆ unblockSemaphore()

size_t nsbaci::services::runtime::NsbaciScheduler::unblockSemaphore ( uint32_t semaphoreAddr)
overridevirtual

Unblock threads waiting on a semaphore.

Parameters
semaphoreAddrThe address of the semaphore.
Returns
Number of threads unblocked.

Implements nsbaci::services::runtime::Scheduler.

◆ yield()

void nsbaci::services::runtime::NsbaciScheduler::yield ( )
overridevirtual

Yield the current thread (move to back of ready queue).

Implements nsbaci::services::runtime::Scheduler.

Here is the call graph for this function:

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