forked from Bananymous/banan-os
Kernel: Separate scheduler execution and stack loading
Not sure if this is actually needed, but this allows actual executing function to be in clean environment
This commit is contained in:
parent
cf4f5f64a5
commit
6b180da4e8
|
@ -31,6 +31,7 @@ namespace Kernel
|
||||||
static bool is_valid_tid(pid_t tid);
|
static bool is_valid_tid(pid_t tid);
|
||||||
|
|
||||||
[[noreturn]] void execute_current_thread();
|
[[noreturn]] void execute_current_thread();
|
||||||
|
[[noreturn]] void _execute_current_thread();
|
||||||
[[noreturn]] void delete_current_process_and_thread();
|
[[noreturn]] void delete_current_process_and_thread();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -7,7 +7,10 @@
|
||||||
#include <kernel/Scheduler.h>
|
#include <kernel/Scheduler.h>
|
||||||
#include <kernel/Timer/PIT.h>
|
#include <kernel/Timer/PIT.h>
|
||||||
|
|
||||||
#if 1
|
#define SCHEDULER_VERIFY_STACK 1
|
||||||
|
#define SCHEDULER_VERIFY_INTERRUPT_STATE 1
|
||||||
|
|
||||||
|
#if SCHEDULER_VERIFY_INTERRUPT_STATE
|
||||||
#define VERIFY_STI() ASSERT(interrupts_enabled())
|
#define VERIFY_STI() ASSERT(interrupts_enabled())
|
||||||
#define VERIFY_CLI() ASSERT(!interrupts_enabled())
|
#define VERIFY_CLI() ASSERT(!interrupts_enabled())
|
||||||
#else
|
#else
|
||||||
|
@ -202,6 +205,7 @@ namespace Kernel
|
||||||
delete thread;
|
delete thread;
|
||||||
|
|
||||||
execute_current_thread();
|
execute_current_thread();
|
||||||
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scheduler::execute_current_thread()
|
void Scheduler::execute_current_thread()
|
||||||
|
@ -210,6 +214,20 @@ namespace Kernel
|
||||||
|
|
||||||
load_temp_stack();
|
load_temp_stack();
|
||||||
PageTable::kernel().load();
|
PageTable::kernel().load();
|
||||||
|
_execute_current_thread();
|
||||||
|
ASSERT_NOT_REACHED();
|
||||||
|
}
|
||||||
|
|
||||||
|
NEVER_INLINE void Scheduler::_execute_current_thread()
|
||||||
|
{
|
||||||
|
VERIFY_CLI();
|
||||||
|
|
||||||
|
#if SCHEDULER_VERIFY_STACK
|
||||||
|
vaddr_t rsp;
|
||||||
|
read_rsp(rsp);
|
||||||
|
ASSERT((vaddr_t)s_temp_stack <= rsp && rsp <= (vaddr_t)s_temp_stack + sizeof(s_temp_stack));
|
||||||
|
ASSERT(&PageTable::current() == &PageTable::kernel());
|
||||||
|
#endif
|
||||||
|
|
||||||
Thread* current = ¤t_thread();
|
Thread* current = ¤t_thread();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue