process: Rewrite ELF loading, processes

This commit is contained in:
2026-10-25 19:12:24 +01:00
parent 9991c1ddcb
commit 0e13d1c0b4
11 changed files with 697 additions and 117 deletions
+15 -2
View File
@@ -8,6 +8,7 @@
#include <zinnia/percpu.h>
#include <zinnia/pmap.h>
#include <zinnia/print.h>
#include <zinnia/process.h>
#include <zinnia/sched.h>
#include <zinnia/spin.h>
#include <zinnia/stack.h>
@@ -57,12 +58,12 @@ void sched_init(struct scheduler* sched) {
tailq_init(&sched->run_queue[i]);
struct task* idle_task;
assert(task_create("idle", &kernel_vma, idle_func, 0, &idle_task) == 0, "Unable to create idle task!");
assert(task_create("idle", process_kernel(), idle_func, 0, &idle_task) == 0, "Unable to create idle task!");
idle_task->last_rq = sched;
sched->idle_task = idle_task;
struct task* boot_task;
assert(task_create_current("boot", &kernel_vma, &boot_task) == 0, "Unable to create boot task!");
assert(task_create_current("boot", process_kernel(), &boot_task) == 0, "Unable to create boot task!");
boot_task->state = TASK_STATE_RUNNING;
boot_task->last_rq = sched;
atomic_store(&boot_task->on_cpu, true, ATOMIC_RELAXED);
@@ -326,6 +327,18 @@ void sched_wake(struct task* task) {
task_unlock(task);
}
void sched_notify(struct task* task) {
task_lock(task);
if (task->state == TASK_STATE_BLOCKED) {
enqueue(select_cpu(task), task);
} else {
atomic_store(&task->wake_pending, true, ATOMIC_RELEASE);
if (task->state == TASK_STATE_RUNNING && task->last_rq && task->last_rq != &percpu_get()->sched)
kick(task->last_rq);
}
task_unlock(task);
}
bool sched_update_priority_locked(struct task* task) {
struct scheduler* sched = task->last_rq;
if (sched == nullptr) {