forked from Bananymous/banan-os
Kernel: Update shell thread command to run following command as thread
'thread echo "Hello World"' runs the command 'echo "Hello World"' after 5 seconds have passed. This was just my test code for threading
This commit is contained in:
parent
5b5e620d8a
commit
cdbad56ed7
|
@ -182,29 +182,29 @@ argument_done:
|
||||||
}
|
}
|
||||||
else if (arguments.front() == "thread")
|
else if (arguments.front() == "thread")
|
||||||
{
|
{
|
||||||
if (arguments.size() != 1)
|
static SpinLock s_thread_spinlock;
|
||||||
{
|
|
||||||
TTY_PRINTLN("'thread' does not support command line arguments");
|
// NOTE: This is a workaround to pass values as copies to threads.
|
||||||
return;
|
// I have only implemented passing integer and pointers.
|
||||||
}
|
// We don't continue execution until the thread has unlocked
|
||||||
//Scheduler::Get().AddThread(
|
// the spinlock.
|
||||||
// [this, arguments]()
|
s_thread_spinlock.lock();
|
||||||
// {
|
Scheduler::get().add_thread(Function<void(const Vector<String>*)>(
|
||||||
// auto start = PIT::ms_since_boot();
|
[this] (const Vector<String>* args_ptr)
|
||||||
// while (PIT::ms_since_boot() < start + 5000);
|
|
||||||
// auto copy = arguments;
|
|
||||||
// copy.remove(0);
|
|
||||||
// ProcessCommand(copy);
|
|
||||||
// }
|
|
||||||
//);
|
|
||||||
Scheduler::get().add_thread(BAN::Function<void()>(
|
|
||||||
[this]()
|
|
||||||
{
|
{
|
||||||
|
auto args = *args_ptr;
|
||||||
|
s_thread_spinlock.unlock();
|
||||||
|
|
||||||
|
args.remove(0);
|
||||||
|
|
||||||
auto start = PIT::ms_since_boot();
|
auto start = PIT::ms_since_boot();
|
||||||
while (PIT::ms_since_boot() < start + 3000);
|
while (PIT::ms_since_boot() < start + 5000);
|
||||||
TTY_PRINTLN("hello");
|
|
||||||
|
process_command(args);
|
||||||
}
|
}
|
||||||
));
|
), &arguments);
|
||||||
|
|
||||||
|
while (s_thread_spinlock.is_locked());
|
||||||
}
|
}
|
||||||
else if (arguments.front() == "memory")
|
else if (arguments.front() == "memory")
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue