Kernel: Scheduler now has reschedule()

This can be called from anywhere and just causes the scheduler to
schedule the next thread. This is more efficient and verbose version
of Scheduler::set_current_thread_sleeping(0), since we don't have
to wake other threads or do other verifications.
This commit is contained in:
Bananymous 2023-06-09 00:47:17 +03:00
parent b7fc2dc3d0
commit 27cef23823
2 changed files with 17 additions and 0 deletions

View File

@ -14,7 +14,9 @@ namespace Kernel
static Scheduler& get(); static Scheduler& get();
[[noreturn]] void start(); [[noreturn]] void start();
void timer_reschedule(); void timer_reschedule();
void reschedule();
void reschedule_if_idling(); void reschedule_if_idling();
void set_current_thread_sleeping(uint64_t); void set_current_thread_sleeping(uint64_t);

View File

@ -84,6 +84,21 @@ namespace Kernel
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
} }
void Scheduler::reschedule()
{
VERIFY_STI();
DISABLE_INTERRUPTS();
if (save_current_thread())
{
ENABLE_INTERRUPTS();
return;
}
advance_current_thread();
execute_current_thread();
ASSERT_NOT_REACHED();
}
void Scheduler::reschedule_if_idling() void Scheduler::reschedule_if_idling()
{ {
VERIFY_CLI(); VERIFY_CLI();