1
This commit is contained in:
2022-12-08 02:14:04 +01:00
parent 1455757e24
commit f5ee5f6942
12 changed files with 536 additions and 501 deletions

View File

@ -5,7 +5,7 @@
*---------------------------------------------------------------------------*
* Beschreibung: Ein Bluescreen, falls eine x86 Exception auftritt. Evt. *
* ist der Stack und oder Heap kaputt, weswegen hier nicht *
* Kernel::kout etc. verwendet wird. *
* Util::System::out etc. verwendet wird. *
* *
* Autor: Michael Schoettner, 11.12.2018 *
*****************************************************************************/

View File

@ -5,7 +5,7 @@
*---------------------------------------------------------------------------*
* Beschreibung: Ein Bluescreen, falls eine x86 Exception auftritt. Evt. *
* ist der Stack und oder Heap kaputt, weswegen hier nicht *
* Kernel::kout etc. verwendet wird. *
* Util::System::out etc. verwendet wird. *
* *
* Autor: Michael Schoettner, 2.2.2017 *
*****************************************************************************/

View File

@ -31,7 +31,7 @@ public:
}
while (true) {
// Kernel::kout << "Idle!" << endl;
// Util::System::out << "Idle!" << endl;
scheduler.yield();
}
}

View File

@ -29,14 +29,6 @@ namespace Kernel {
constexpr const bool INSANE_TRACE = false;
/*****************************************************************************
* Methode: Dispatcher::dispatch *
*---------------------------------------------------------------------------*
* Beschreibung: Auf den active thread wechseln. *
* *
* Parameter: *
* next Thread der die CPU::erhalten soll. *
*****************************************************************************/
void Scheduler::start(Container::Vector<Memory::unique_ptr<Thread>>::iterator next) {
active = next;
if (active >= ready_queue.end()) {
@ -139,7 +131,8 @@ void Scheduler::kill(uint32_t tid, Memory::unique_ptr<Thread> *ptr) {
uint32_t prev_tid = (*active)->tid;
// Block queue, can always kill
for (Container::Vector<Memory::unique_ptr<Thread>>::iterator it = block_queue.begin(); it != block_queue.end(); ++it) {
for (Container::Vector<Memory::unique_ptr<Thread>>::iterator it = block_queue.begin();
it != block_queue.end(); ++it) {
if ((*it)->tid == tid) {
// Found thread to kill
@ -165,7 +158,8 @@ void Scheduler::kill(uint32_t tid, Memory::unique_ptr<Thread> *ptr) {
return;
}
for (Container::Vector<Memory::unique_ptr<Thread>>::iterator it = ready_queue.begin(); it != ready_queue.end(); ++it) {
for (Container::Vector<Memory::unique_ptr<Thread>>::iterator it = ready_queue.begin();
it != ready_queue.end(); ++it) {
if ((*it)->tid == tid) {
// Found thread to kill
@ -322,7 +316,8 @@ void Scheduler::deblock(uint32_t tid) {
Device::CPU::disable_int();
for (Container::Vector<Memory::unique_ptr<Thread>>::iterator it = block_queue.begin(); it != block_queue.end(); ++it) {
for (Container::Vector<Memory::unique_ptr<Thread>>::iterator it = block_queue.begin();
it != block_queue.end(); ++it) {
if ((*it)->tid == tid) {
// Found thread with correct tid

View File

@ -13,7 +13,7 @@
#define Scheduler_include__
#include "Thread.h"
#include "lib/mem/UniquePointer.h"
#include "lib/memory/UniquePointer.h"
#include "lib/stream/Logger.h"
#include "lib/container/Vector.h"
@ -26,17 +26,20 @@ private:
Container::Vector<Memory::unique_ptr<Thread>> ready_queue;
Container::Vector<Memory::unique_ptr<Thread>> block_queue;
// NOTE: It makes sense to keep track of the active thread through this as it makes handling the
// unique_ptr easier and reduces the copying in the vector when cycling through the threads
// It makes sense to keep track of the active thread through this as it makes handling the
// unique_ptr easier and reduces the copying in the vector when cycling through the threads
// as we don't have to keep the active thread at the front (would only make sense with a queue)
Container::Vector<Memory::unique_ptr<Thread>>::iterator active = nullptr;
// Scheduler wird evt. von einer Unterbrechung vom Zeitgeber gerufen,
// bevor er initialisiert wurde
uint32_t idle_tid = 0U;
uint32_t idle_tid = 0;
// Roughly the old dispatcher functionality
void start(Container::Vector<Memory::unique_ptr<Thread>>::iterator next); // Start next without prev
void switch_to(Thread *prev_raw, Container::Vector<Memory::unique_ptr<Thread>>::iterator next); // Switch from prev to next
void
start(Container::Vector<Memory::unique_ptr<Thread>>::iterator next); // Start next without prev
void switch_to(Thread *prev_raw,
Container::Vector<Memory::unique_ptr<Thread>>::iterator next); // Switch from prev to next
// Kann nur vom Idle-Thread aufgerufen werden (erster Thread der vom Scheduler gestartet wird)
void enable_preemption(uint32_t tid) { idle_tid = tid; }
@ -56,14 +59,14 @@ public:
block_queue.reserve();
}
uint32_t get_active() const {
[[nodiscard]] uint32_t get_active() const {
return (*active)->tid;
}
// Scheduler initialisiert?
// Zeitgeber-Unterbrechung kommt evt. bevor der Scheduler fertig
// intiialisiert wurde!
bool preemption_enabled() const { return idle_tid != 0U; }
[[nodiscard]] bool preemption_enabled() const { return idle_tid != 0U; }
// Scheduler starten
void schedule();