Manage int IDs via id_alloc
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m31s

This commit is contained in:
2026-02-22 20:40:12 +01:00
parent 8fc5418915
commit 084809ac99
13 changed files with 203 additions and 70 deletions

View File

@@ -17,8 +17,6 @@
#include <sys/debug.h>
#include <sys/proc.h>
static atomic_int pids = 0;
struct proc* proc_from_elf (uint8_t* elf_contents) {
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
@@ -30,7 +28,12 @@ struct proc* proc_from_elf (uint8_t* elf_contents) {
proc->lock = SPIN_LOCK_INIT;
proc->state = PROC_READY;
proc->pid = atomic_fetch_add (&pids, 1);
proc->pid = proc_alloc_pid ();
if (proc->pid < 0) {
free (proc);
return NULL;
}
proc->procgroup = procgroup_create ();
if (proc->procgroup == NULL) {
@@ -72,7 +75,12 @@ struct proc* proc_clone (struct proc* proto, uintptr_t vstack_top, uintptr_t ent
proc->lock = SPIN_LOCK_INIT;
proc->state = PROC_READY;
proc->pid = atomic_fetch_add (&pids, 1);
proc->pid = proc_alloc_pid ();
if (proc->pid < 0) {
free (proc);
return NULL;
}
spin_lock (&proto->lock);
@@ -108,6 +116,7 @@ void proc_cleanup (struct proc* proc, struct reschedule_ctx* rctx) {
procgroup_detach (proc->procgroup, proc, rctx);
proc_free_pid (proc->pid);
/* clean the process */
free (proc);
}