![]() |
nsbaci 1.0
|
BACI-specific implementation of the Scheduler. More...
#include <nsbaciScheduler.h>


Public Member Functions | |
| Thread * | pickNext () 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. | |
| Thread * | current () 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< Thread > | threads |
| 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. | |
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.
|
overridevirtual |
Add a new thread to the scheduler.
| thread | The thread to add. |
Implements nsbaci::services::runtime::Scheduler.

|
overridevirtual |
Block the currently running thread.
Implements nsbaci::services::runtime::Scheduler.

|
overridevirtual |
Block current thread on coend (waiting for spawned threads).
| expectedThreads | Number of threads that should terminate. |
Implements nsbaci::services::runtime::Scheduler.

|
overridevirtual |
Block current thread on a semaphore.
| semaphoreAddr | The address of the semaphore. |
Implements nsbaci::services::runtime::Scheduler.

|
overridevirtual |
Check if coend-blocked threads should be unblocked.
Called after a thread terminates.
Implements nsbaci::services::runtime::Scheduler.

|
overridevirtual |
Clear all threads and reset scheduler state.
Implements nsbaci::services::runtime::Scheduler.
|
overridevirtual |
Get the currently running thread.
Implements nsbaci::services::runtime::Scheduler.

|
overridevirtual |
Get all threads managed by the scheduler.
Implements nsbaci::services::runtime::Scheduler.
|
overridevirtual |
Check if there are any threads left to run.
Implements nsbaci::services::runtime::Scheduler.
|
overridevirtual |
Pick the next thread to run.
Implements nsbaci::services::runtime::Scheduler.

|
overridevirtual |
Terminate the currently running thread.
Implements nsbaci::services::runtime::Scheduler.

|
overridevirtual |
Move a thread from blocked to ready state.
| threadId | The ID of the thread to unblock. |
Implements nsbaci::services::runtime::Scheduler.
|
overridevirtual |
Move all I/O waiting threads back to ready queue.
Called when input becomes available.
Implements nsbaci::services::runtime::Scheduler.
|
overridevirtual |
Unblock threads waiting on a semaphore.
| semaphoreAddr | The address of the semaphore. |
Implements nsbaci::services::runtime::Scheduler.
|
overridevirtual |
Yield the current thread (move to back of ready queue).
Implements nsbaci::services::runtime::Scheduler.
