Store the stack inside a thread

This commit is contained in:
apio 2022-12-18 18:43:17 +01:00
parent 00cf267ac7
commit 1b92fe36b4
Signed by: apio
GPG Key ID: B8A7D06E42258954
3 changed files with 8 additions and 0 deletions

View File

@ -29,6 +29,8 @@ namespace Scheduler
Stack idle_stack{idle_stack_vm, ARCH_PAGE_SIZE}; Stack idle_stack{idle_stack_vm, ARCH_PAGE_SIZE};
g_idle.set_sp(idle_stack.top()); g_idle.set_sp(idle_stack.top());
g_idle.stack = idle_stack;
kinfoln("CREATED IDLE THREAD: id %lu with ip %lx and sp %lx", g_idle.id, g_idle.ip(), g_idle.sp()); kinfoln("CREATED IDLE THREAD: id %lu with ip %lx and sp %lx", g_idle.id, g_idle.ip(), g_idle.sp());
g_current = &g_idle; g_current = &g_idle;
@ -56,6 +58,8 @@ namespace Scheduler
Stack thread_stack{thread_stack_vm, ARCH_PAGE_SIZE * 4}; Stack thread_stack{thread_stack_vm, ARCH_PAGE_SIZE * 4};
thread->set_sp(thread_stack.top()); thread->set_sp(thread_stack.top());
thread->stack = thread_stack;
g_threads.append(thread); g_threads.append(thread);
kinfoln("CREATED THREAD: id %lu with ip %lx and sp %lx", thread->id, thread->ip(), thread->sp()); kinfoln("CREATED THREAD: id %lu with ip %lx and sp %lx", thread->id, thread->ip(), thread->sp());

View File

@ -2,6 +2,7 @@
#include <luna/LinkedList.h> #include <luna/LinkedList.h>
#include <luna/Result.h> #include <luna/Result.h>
#include <luna/Stack.h>
#ifdef ARCH_X86_64 #ifdef ARCH_X86_64
#include "arch/x86_64/CPU.h" #include "arch/x86_64/CPU.h"
@ -29,6 +30,8 @@ struct Thread : public DoublyLinkedListNode<Thread>
u64 ticks_left; u64 ticks_left;
u64 sleep_ticks_left; u64 sleep_ticks_left;
Stack stack;
ThreadState state = ThreadState::Runnable; ThreadState state = ThreadState::Runnable;
bool is_idle() bool is_idle()

View File

@ -3,6 +3,7 @@
struct Stack struct Stack
{ {
Stack() = default;
Stack(u64 base, usize bytes); Stack(u64 base, usize bytes);
u64 bottom() u64 bottom()