Manage int IDs via id_alloc
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m31s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m31s
This commit is contained in:
@@ -64,6 +64,9 @@ void bootmain (void) {
|
||||
spin ();
|
||||
}
|
||||
|
||||
proc_pid_alloc_init ();
|
||||
procgroup_pgid_alloc_init ();
|
||||
|
||||
smp_init ();
|
||||
|
||||
proc_init ();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user