nsbaci 1.0
Loading...
Searching...
No Matches
nsbaciScheduler.h
Go to the documentation of this file.
1
12
13#ifndef NSBACI_SERVICES_RUNTIME_NSBACI_SCHEDULER_H
14#define NSBACI_SERVICES_RUNTIME_NSBACI_SCHEDULER_H
15
16#include "scheduler.h"
17
23
33class NsbaciScheduler final : public Scheduler {
34 public:
35 NsbaciScheduler() = default;
36 ~NsbaciScheduler() override = default;
37
38 Thread* pickNext() override;
39 void addThread(Thread thread) override;
40 void blockCurrent() override;
41 void blockOnSemaphore(uint32_t semaphoreAddr) override;
42 size_t unblockSemaphore(uint32_t semaphoreAddr) override;
43 void unblock(nsbaci::types::ThreadID threadId) override;
44 void yield() override;
45 void terminateCurrent() override;
46 bool hasThreads() const override;
47 Thread* current() override;
48 void clear() override;
49 void unblockIO() override;
50 const std::vector<Thread>& getThreads() const override;
51 void blockOnCoend(int32_t expectedThreads) override;
52 void checkCoendUnblock() override;
53
54 private:
60 std::optional<size_t> findThreadIndex(nsbaci::types::ThreadID threadId) const;
61};
62
63} // namespace nsbaci::services::runtime
64
65#endif // NSBACI_SERVICES_RUNTIME_NSBACI_SCHEDULER_H
void terminateCurrent() override
Terminate the currently running thread.
Definition nsbaciScheduler.cpp:130
void unblock(nsbaci::types::ThreadID threadId) override
Move a thread from blocked to ready state.
Definition nsbaciScheduler.cpp:107
void clear() override
Clear all threads and reset scheduler state.
Definition nsbaciScheduler.cpp:156
void blockOnCoend(int32_t expectedThreads) override
Block current thread on coend (waiting for spawned threads).
Definition nsbaciScheduler.cpp:189
void blockCurrent() override
Block the currently running thread.
Definition nsbaciScheduler.cpp:64
size_t unblockSemaphore(uint32_t semaphoreAddr) override
Unblock threads waiting on a semaphore.
Definition nsbaciScheduler.cpp:86
void yield() override
Yield the current thread (move to back of ready queue).
Definition nsbaciScheduler.cpp:119
void unblockIO() override
Move all I/O waiting threads back to ready queue.
Definition nsbaciScheduler.cpp:166
const std::vector< Thread > & getThreads() const override
Get all threads managed by the scheduler.
Definition nsbaciScheduler.cpp:175
Thread * pickNext() override
Pick the next thread to run.
Definition nsbaciScheduler.cpp:16
void blockOnSemaphore(uint32_t semaphoreAddr) override
Block current thread on a semaphore.
Definition nsbaciScheduler.cpp:75
Thread * current() override
Get the currently running thread.
Definition nsbaciScheduler.cpp:149
bool hasThreads() const override
Check if there are any threads left to run.
Definition nsbaciScheduler.cpp:144
void checkCoendUnblock() override
Check if coend-blocked threads should be unblocked.
Definition nsbaciScheduler.cpp:200
void addThread(Thread thread) override
Add a new thread to the scheduler.
Definition nsbaciScheduler.cpp:57
Represents a thread in the runtime service.
Definition thread.h:31
Runtime services namespace for nsbaci.
Scheduler class declaration for nsbaci runtime service.