Luna/kernel/src/thread/Task.cpp
apio a6f0a7056f Scheduler: Set the user_task field in a Task at creation time
We were previously looking at its segment registers to see if they were user-like, but this method is bad.
What is the task was executing a system call?

So now, we store that value at creation time.
2022-10-12 17:07:39 +02:00

29 lines
591 B
C++

#include "thread/Task.h"
#include "std/string.h"
void set_context_from_task(Task& task, Context* ctx)
{
memcpy(ctx, &task.regs, sizeof(Context));
}
void get_context_to_task(Task& task, Context* ctx)
{
memcpy(&task.regs, ctx, sizeof(Context));
}
void task_save_floating(Task& task)
{
task.floating_saved = true;
asm volatile("fxsave (%0)" : : "r"(&task.floating_region));
}
void task_restore_floating(Task& task)
{
if (!task.floating_saved) return;
asm volatile("fxrstor (%0)" : : "r"(&task.floating_region));
}
bool Task::is_user_task()
{
return user_task;
}