Kernel: Replace last CriticalScopes in kernel with SpinLocks

This commit is contained in:
2024-03-01 15:49:39 +02:00
parent 054b41383f
commit 8d7dd577ab
5 changed files with 68 additions and 71 deletions

View File

@@ -30,9 +30,12 @@ namespace Kernel
static pid_t current_tid();
[[noreturn]] void execute_current_thread();
[[noreturn]] void _execute_current_thread();
[[noreturn]] void execute_current_thread_locked();
[[noreturn]] void delete_current_process_and_thread();
// This is no return if called on current thread
void terminate_thread(Thread*);
private:
Scheduler() = default;
@@ -43,6 +46,8 @@ namespace Kernel
void remove_and_advance_current_thread();
void advance_current_thread();
[[noreturn]] void execute_current_thread_stack_loaded();
BAN::ErrorOr<void> add_thread(Thread*);
private:
@@ -57,6 +62,8 @@ namespace Kernel
Semaphore* semaphore;
};
SpinLockUnsafe m_lock;
Thread* m_idle_thread { nullptr };
BAN::LinkedList<SchedulerThread> m_active_threads;
BAN::LinkedList<SchedulerThread> m_sleeping_threads;

View File

@@ -65,8 +65,6 @@ namespace Kernel
uintptr_t rip() const { return m_rip; }
void set_started() { ASSERT(m_state == State::NotStarted); m_state = State::Executing; }
// Thread will no longer execute. If called on current thread, does not return
void terminate();
State state() const { return m_state; }
vaddr_t stack_base() const { return m_stack->vaddr(); }