Merge branch 'main' of gitlab.ibr.cs.tu-bs.de:vss/teaching/ws25/v_bsb2/stubsmi
This commit is contained in:
@@ -32,15 +32,13 @@ void Scheduler::resume(bool ready) {
|
||||
Thread *me = dispatcher.active();
|
||||
assert(me != nullptr && "Pointer to active thread should never be nullptr");
|
||||
|
||||
if (true) {
|
||||
// Be careful, never put the idle thread into the ready list
|
||||
bool is_idle_thread = static_cast<Thread *>(&idleThread) == me;
|
||||
// Be careful, never put the idle thread into the ready list
|
||||
bool is_idle_thread = static_cast<Thread *>(&idleThread) == me;
|
||||
|
||||
if (ready && readylist.is_empty()) {
|
||||
return;
|
||||
} else if (!is_idle_thread) {
|
||||
if (ready) readylist.enqueue(*me);
|
||||
}
|
||||
if (ready && readylist.is_empty()) {
|
||||
return;
|
||||
} else if (!is_idle_thread) {
|
||||
if (ready) readylist.enqueue(*me);
|
||||
}
|
||||
|
||||
dispatcher.dispatch(getNext());
|
||||
@@ -56,6 +54,8 @@ void Scheduler::kill(Thread *that) {
|
||||
if (dispatcher.active() == that) {
|
||||
exit();
|
||||
}
|
||||
|
||||
readylist.remove(that);
|
||||
}
|
||||
|
||||
bool Scheduler::isEmpty() const { return readylist.is_empty(); }
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
#include "../interrupt/guard.h"
|
||||
#include "debug/output.h"
|
||||
|
||||
// counter for ID
|
||||
static size_t idCounter = 1;
|
||||
static int idCounter = 1; // counter for task IDs
|
||||
|
||||
void Thread::kickoff(uintptr_t param1, uintptr_t param2, uintptr_t param3) {
|
||||
Thread *thread = reinterpret_cast<Thread *>(param1);
|
||||
|
||||
@@ -38,7 +38,6 @@ class Thread {
|
||||
// alignas(16) char reserved_stack_space_user[STACK_SIZE];
|
||||
alignas(16) char reserved_stack_space_isr[STACK_SIZE];
|
||||
|
||||
protected:
|
||||
/*! \brief Context of the thread, used for saving and restoring the register
|
||||
* values when context switching.
|
||||
*/
|
||||
@@ -59,6 +58,7 @@ class Thread {
|
||||
* \param param1 Thread to be started
|
||||
* \param param2 Second parameter (will be used later)
|
||||
* \param param3 Third parameter (will be used later)
|
||||
*
|
||||
*/
|
||||
static void kickoff(uintptr_t param1, uintptr_t param2, uintptr_t param3);
|
||||
|
||||
@@ -72,7 +72,7 @@ class Thread {
|
||||
void* operator new ( size_t count )noexcept;
|
||||
|
||||
/*! \brief Unique thread id */
|
||||
const size_t id;
|
||||
const int id;
|
||||
|
||||
|
||||
|
||||
@@ -81,6 +81,13 @@ class Thread {
|
||||
*/
|
||||
volatile bool kill_flag;
|
||||
|
||||
// Naively moving or copying esp. the (user) stack of a thread would be a
|
||||
// bad idea:
|
||||
Thread(const Thread&) = delete;
|
||||
Thread(Thread&&) = delete;
|
||||
Thread& operator=(const Thread&) = delete;
|
||||
Thread& operator=(Thread&&) = delete;
|
||||
|
||||
/*! \brief Constructor
|
||||
* Initializes the context using \ref prepareContext with the thread's
|
||||
* stack space.
|
||||
|
||||
Reference in New Issue
Block a user