feat: added task names

This commit is contained in:
2021-08-12 20:22:00 +02:00
parent be71f9a7e9
commit 94c6332e27
7 changed files with 32 additions and 12 deletions

View File

@@ -27,19 +27,22 @@
int errno = 0;
typedef struct task {
// state
bool present: 1;
uint8_t state;
uint16_t wait_irq;
// identity
pid_t tid;
char* name;
int errno;
// linked list
struct task *next;
// persistence/memory
int errno;
void *stack;
uint32_t stack_page_count;
task_registers_t *task_registers;
} task_t;
@@ -240,10 +243,11 @@ void task_switch_next() {
task_switch_next_inner(task_first_runnable());
}
task_t *task_create(task_entrypoint entrypoint, void *entry_data) {
task_t *task_create(task_entrypoint entrypoint, void *entry_data, char* name) {
task_t *new_task = malloc(sizeof(task_t));
memset((uint8_t *) new_task, 0, sizeof(task_t));
new_task->tid = last_tid++;
new_task->name = strdup(name);
new_task->state = TASK_STATE_RUNNABLE;
new_task->stack = pmm_get_pages(16);
@@ -281,12 +285,12 @@ void task_free(task_t *task) {
}
void task_init() {
idle_task = task_create(task_idle, NULL);
reaper_pid = task_spawn(task_reaper, NULL);
idle_task = task_create(task_idle, NULL, "idle");
reaper_pid = task_spawn(task_reaper, NULL, "reaper");
}
pid_t task_spawn(task_entrypoint entrypoint, void *entry_data) {
task_t *new_task = task_create(entrypoint, entry_data);
pid_t task_spawn(task_entrypoint entrypoint, void *entry_data, char* name) {
task_t *new_task = task_create(entrypoint, entry_data, name);
if (first_task == NULL) {
// first task
first_task = new_task;