Use a big-lock for kernel sychronization instead of fine-grained locking
All checks were successful
Build ISO image / build-and-deploy (push) Successful in 2m21s
Build documentation / build-and-deploy (push) Successful in 54s

This commit is contained in:
2026-04-27 18:06:02 +02:00
parent 68cdd8d6d2
commit e5ebd7f3ba
56 changed files with 212 additions and 1206 deletions

View File

@@ -29,7 +29,6 @@ struct proc* proc_from_elf(uint8_t* elf_contents) {
memset(proc, 0, sizeof(*proc));
proc->lock = SPIN_LOCK_INIT;
proc->state = PROC_READY;
proc->pid = proc_alloc_pid();
@@ -69,7 +68,6 @@ struct proc* proc_from_elf(uint8_t* elf_contents) {
struct proc* proc_clone(struct proc* proto, uintptr_t vstack_top, uintptr_t entry,
uintptr_t argument_ptr) {
uint64_t fpt;
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
struct proc* proc = malloc(sizeof(*proc));
@@ -78,7 +76,6 @@ struct proc* proc_clone(struct proc* proto, uintptr_t vstack_top, uintptr_t entr
memset(proc, 0, sizeof(*proc));
proc->lock = SPIN_LOCK_INIT;
proc->state = PROC_READY;
proc->pid = proc_alloc_pid();
@@ -87,15 +84,11 @@ struct proc* proc_clone(struct proc* proto, uintptr_t vstack_top, uintptr_t entr
return NULL;
}
spin_lock(&proto->lock, &fpt);
memcpy(proc->name, proto->name, sizeof(proto->name));
proc->procgroup = proto->procgroup;
procgroup_attach(proc->procgroup, proc);
spin_unlock(&proto->lock, fpt);
uintptr_t kstack_paddr = pmm_alloc(KSTACK_SIZE / PAGE_SIZE);
proc->pdata.kernel_stack = kstack_paddr + (uintptr_t)hhdm->offset + KSTACK_SIZE;
@@ -116,28 +109,14 @@ struct proc* proc_clone(struct proc* proto, uintptr_t vstack_top, uintptr_t entr
}
void proc_cleanup(struct proc* proc, struct reschedule_ctx* rctx) {
uint64_t fp, fsq;
spin_lock(&proc->lock, &fp);
spin_lock(&proc->done_sq.lock, &fsq);
while (proc->done_sq.proc_list != NULL) {
struct list_node_link* node = proc->done_sq.proc_list;
struct proc_sq_entry* sq_entry = list_entry(node, struct proc_sq_entry, sq_link);
struct proc* suspended_proc = sq_entry->proc;
spin_unlock(&proc->done_sq.lock, fsq);
spin_unlock(&proc->lock, fp);
proc_sq_resume(suspended_proc, sq_entry, rctx);
spin_lock(&proc->lock, &fp);
spin_lock(&proc->done_sq.lock, &fsq);
}
spin_unlock(&proc->done_sq.lock, fsq);
spin_unlock(&proc->lock, fp);
proc_sqs_cleanup(proc);
proc_mutexes_cleanup(proc, rctx);