Kernel: Shell's thread now uses sleep instead of polling

Also added 'sleep' command that just sleeps for 5 seconds
This commit is contained in:
Bananymous 2023-02-19 17:54:11 +02:00
parent 1bd8b0fe5c
commit 0506fee34a
1 changed files with 13 additions and 7 deletions

View File

@ -189,20 +189,16 @@ argument_done:
// We don't continue execution until the thread has unlocked
// the spinlock.
s_thread_spinlock.lock();
Scheduler::get().add_thread(Function<void(const Vector<String>*)>(
MUST(Scheduler::get().add_thread(Function<void(const Vector<String>*)>(
[this] (const Vector<String>* args_ptr)
{
auto args = *args_ptr;
s_thread_spinlock.unlock();
args.remove(0);
auto start = PIT::ms_since_boot();
while (PIT::ms_since_boot() < start + 5000);
PIT::sleep(5000);
process_command(args);
}
), &arguments);
), &arguments));
while (s_thread_spinlock.is_locked());
}
@ -215,6 +211,16 @@ argument_done:
}
kmalloc_dump_info();
}
else if (arguments.front() == "sleep")
{
if (arguments.size() != 1)
{
TTY_PRINTLN("'sleep' does not support command line arguments");
return;
}
PIT::sleep(5000);
TTY_PRINTLN("done");
}
else if (arguments.front() == "cpuinfo")
{
if (arguments.size() != 1)