kernel: Add a kernel_wait_for_event() function to avoid weird calls to kernel_wait in kthreads
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
4a7f68b989
commit
293a992133
@ -128,10 +128,10 @@ void io_thread()
|
||||
while (true)
|
||||
{
|
||||
u8 scancode;
|
||||
while (!scancode_queue.try_pop(scancode)) { kernel_wait(0); }
|
||||
while (!scancode_queue.try_pop(scancode)) kernel_wait_for_event();
|
||||
|
||||
char key;
|
||||
if (Keyboard::decode_scancode(scancode).try_set_value(key)) { ConsoleDevice::did_press_key(key); }
|
||||
if (Keyboard::decode_scancode(scancode).try_set_value(key)) ConsoleDevice::did_press_key(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ void reap_thread()
|
||||
|
||||
dying_threads.consume([](Thread* thread) { Scheduler::reap_thread(thread); });
|
||||
|
||||
kernel_wait(0);
|
||||
kernel_wait_for_event();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,6 +365,12 @@ void kernel_wait(pid_t pid)
|
||||
kernel_yield();
|
||||
}
|
||||
|
||||
void kernel_wait_for_event()
|
||||
{
|
||||
g_current->state = ThreadState::Waiting;
|
||||
kernel_yield();
|
||||
}
|
||||
|
||||
[[noreturn]] void kernel_exit()
|
||||
{
|
||||
g_current->state = ThreadState::Dying;
|
||||
|
@ -56,3 +56,6 @@ extern "C" void kernel_yield();
|
||||
void kernel_wait(pid_t pid);
|
||||
void kernel_sleep(u64 ms);
|
||||
[[noreturn]] void kernel_exit();
|
||||
|
||||
// Freezes the current thread until someone else calls wake_up() on this thread.
|
||||
void kernel_wait_for_event();
|
||||
|
Loading…
Reference in New Issue
Block a user