Luna/kernel/include/thread/Task.h
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

52 lines
909 B
C

#pragma once
#include "fs/FileDescriptor.h"
#include "interrupts/Context.h"
#include "sys/elf/Image.h"
#define TASK_MAX_FDS 8
struct Task
{
enum TaskState
{
Idle,
Running,
Sleeping,
Exited
};
uint64_t id;
Context regs;
int64_t task_sleep = 0;
int64_t exit_status;
int64_t task_time = 0;
Task* next_task = nullptr;
Task* prev_task = nullptr;
uint64_t allocated_stack = 0;
TaskState state;
uint64_t cpu_time = 0;
char floating_region[512] __attribute__((aligned(16)));
bool floating_saved = false;
bool user_task = true;
bool is_user_task();
ELFImage* image = nullptr;
Descriptor files[TASK_MAX_FDS];
};
void set_context_from_task(Task& task, Context* ctx);
void get_context_to_task(Task& task, Context* ctx);
void task_save_floating(Task& task);
void task_restore_floating(Task& task);