feature: fork added and exit_task is almost working

This commit is contained in:
2025-01-28 13:38:39 +01:00
parent d7626df19c
commit dbdf851dd2
9 changed files with 80 additions and 19 deletions

View File

@ -1,3 +1,4 @@
#include "alloc.h"
#include "debug.h"
#include "kprintf.h"
#include "task.h"
@ -5,14 +6,20 @@
#include <stddef.h>
struct task *current_task = NULL;
struct task *current_task;
void scheduler(void)
{
if (!current_task || current_task->next == current_task)
if (!current_task) // || current_task->next == current_task)
return;
struct task *it = current_task->next;
while (it && it->status != RUN)
while (it && it->status != RUN) {
if (it->status == STOPPED || it->status == ZOMBIE) {
struct task *new_it = it->prev;
remove_task(it);
it = new_it;
}
it = it->next;
}
switch_to_task(it);
}