rumgedümpel

main
Eggert Jung 4 months ago
parent 5b664840d8
commit 68e11c9793

@ -12,6 +12,7 @@
#include "device/textstream.h" #include "device/textstream.h"
#include "device/ps2controller.h" #include "device/ps2controller.h"
#include "arch/ioapic.h" #include "arch/ioapic.h"
#include "thread/scheduler.h"
#include "user/app1/appl.h" #include "user/app1/appl.h"
#include "sync/ticketlock.h" #include "sync/ticketlock.h"
#include "interrupt/guard.h" #include "interrupt/guard.h"
@ -71,32 +72,32 @@ unsigned int testx, testy;
Context test1; Context test1;
uint8_t test1_stack[256]; uint8_t test1_stack[256];
Thread test1_thread = Thread(&test1_stack[sizeof(test1_stack)-1]); //Thread test1_thread = Thread(&test1_stack[sizeof(test1_stack)-1]);
//Application application = Application(test1_stack); Application application = Application(test1_stack);
Context test2; //Context test2;
uint8_t test2_stack[256]; //uint8_t test2_stack[256];
Thread test2_thread = Thread(&test2_stack[sizeof(test2_stack)-1]); //Thread test2_thread = Thread(&test2_stack[sizeof(test2_stack)-1]);
void test_func1(){ //void test_func1(){
while(1){ // while(1){
{ // {
Guarded g = Guard::enter(); // Guarded g = Guard::enter();
g.vault().kout << "test 1\n" << flush; // g.vault().kout << "test 1\n" << flush;
} // }
context_switch(&test2, &test1); // context_switch(&test2, &test1);
} // }
} //}
//
void test_func2(){ //void test_func2(){
while(1){ // while(1){
{ // {
Guarded g = Guard::enter(); // Guarded g = Guard::enter();
g.vault().kout << "test 2\n" << flush; // g.vault().kout << "test 2\n" << flush;
} // }
context_switch(&test1, &test2); // context_switch(&test1, &test2);
} // }
} //}
@ -126,7 +127,10 @@ extern "C" int main() {
DBG << "Main CPU " << static_cast<int>(LAPIC::getID()) << endl << flush; DBG << "Main CPU " << static_cast<int>(LAPIC::getID()) << endl << flush;
test1_thread.go(); Scheduler sch;
sch.ready(&application);
sch.schedule();
//Application{}.action(); //Application{}.action();
while (true){ while (true){

@ -1,7 +1,7 @@
// vim: set noet ts=4 sw=4: // vim: set noet ts=4 sw=4:
#include "dispatcher.h" #include "dispatcher.h"
#include "core.h" #include "../arch/core.h"
Dispatcher::Dispatcher() { Dispatcher::Dispatcher() {
} }

@ -6,7 +6,7 @@
#pragma once #pragma once
#include "../thread/thread.h" #include "../thread/thread.h"
#include "../types.h" #include "../types.h"
#include "core.h" #include "../arch/core.h"
/*! \brief The dispatcher dispatches threads and puts the scheduler's /*! \brief The dispatcher dispatches threads and puts the scheduler's
* decisions into action. * decisions into action.

@ -22,7 +22,8 @@ void Scheduler::ready(Thread* that) {
} }
void Scheduler::resume(bool ready) { void Scheduler::resume(bool ready) {
if (!active()->kill_flag) if (ready)
//if (!active()->kill_flag)
readyList.enqueue(*active()); readyList.enqueue(*active());
Thread* thread = readyList.dequeue(); Thread* thread = readyList.dequeue();
assert(thread != nullptr); assert(thread != nullptr);

Loading…
Cancel
Save