scheduler + 2 instances of application
This commit is contained in:
@@ -27,6 +27,6 @@ void Dispatcher::go(Thread *first) {
|
||||
}
|
||||
|
||||
void Dispatcher::dispatch(Thread *next) {
|
||||
lifePointer[Core::getID()] = next;
|
||||
//lifePointer[Core::getID()] = next;
|
||||
lifePointer[Core::getID()]->resume(next);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ class Dispatcher {
|
||||
*/
|
||||
void setActive(Thread* thread) { (void)thread; }
|
||||
|
||||
Thread* lifePointer[Core::MAX];
|
||||
|
||||
public:
|
||||
/*! \brief constructor
|
||||
@@ -32,6 +31,7 @@ class Dispatcher {
|
||||
* \todo(14) Implement Method
|
||||
*/
|
||||
Dispatcher();
|
||||
Thread* lifePointer[Core::MAX];
|
||||
|
||||
/*! \brief Returns the thread currently running on the CPU core calling
|
||||
* this method
|
||||
|
||||
@@ -22,8 +22,8 @@ void Scheduler::ready(Thread* that) {
|
||||
}
|
||||
|
||||
void Scheduler::resume(bool ready) {
|
||||
if (ready)
|
||||
//if (!active()->kill_flag)
|
||||
if (ready)
|
||||
readyList.enqueue(*active());
|
||||
Thread* thread = readyList.dequeue();
|
||||
assert(thread != nullptr);
|
||||
|
||||
@@ -22,12 +22,7 @@
|
||||
* taken from the front of the queue.
|
||||
*/
|
||||
class Scheduler {
|
||||
/*! \brief a Dispatcher object, providing the low level context switching
|
||||
* routines.
|
||||
*/
|
||||
Dispatcher dispatcher;
|
||||
|
||||
/*! \brief Helper to retrieve next Thread
|
||||
/*! \brief Helper to retrieve next Thread
|
||||
* \return pointer of next thread
|
||||
*/
|
||||
Thread* getNext();
|
||||
@@ -36,6 +31,12 @@ class Scheduler {
|
||||
public:
|
||||
Scheduler();
|
||||
|
||||
/*! \brief a Dispatcher object, providing the low level context switching
|
||||
* routines.
|
||||
*/
|
||||
Dispatcher dispatcher;
|
||||
|
||||
|
||||
/*! \brief Start scheduling
|
||||
*
|
||||
* This method starts the scheduling by removing the first thread from
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// vim: set noet ts=4 sw=4:
|
||||
|
||||
#include "thread.h"
|
||||
#include "../debug/output.h"
|
||||
#include "../arch/context.h"
|
||||
|
||||
// Alias to simplify stuff
|
||||
@@ -14,8 +15,16 @@ Thread::Thread(void* tos) {
|
||||
prepareContext(tos, context, (void(*)(void*)) &(kickoff), this);
|
||||
}
|
||||
|
||||
#include "../thread/scheduler.h"
|
||||
extern Scheduler sch;
|
||||
void Thread::resume(Thread* next) {
|
||||
context_switch(&next->context, &context);
|
||||
Context *from = &sch.active()->context;
|
||||
Context *to = &next->context;
|
||||
|
||||
sch.dispatcher.lifePointer[Core::getID()] = next;
|
||||
DBG << "from: " << hex << from << endl;
|
||||
DBG << "to : " << hex << to << endl << flush;
|
||||
context_switch(to, from);
|
||||
}
|
||||
|
||||
void Thread::go() {
|
||||
|
||||
Reference in New Issue
Block a user