apio
f83a6ace51
The exit() libc function already accepted an integer, but didn't pass it on to the kernel since we had no mechanism for it to do that. Now, the kernel stores a task's exit status to display it later (and in the future, return it to userspace via wait()/waitpid())
45 lines
789 B
C
45 lines
789 B
C
#pragma once
|
|
#include "interrupts/Context.h"
|
|
#include "sys/elf/Image.h"
|
|
|
|
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 is_user_task();
|
|
|
|
ELFImage* image = nullptr;
|
|
};
|
|
|
|
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); |