Remove spinlock contexts
All checks were successful
Build documentation / build-and-deploy (push) Successful in 28s

This commit is contained in:
2026-02-08 18:58:53 +01:00
parent 1ca3d11bac
commit 9e6035bd68
26 changed files with 161 additions and 262 deletions

View File

@@ -9,24 +9,23 @@
#include <sys/spin_lock.h>
bool proc_sq_suspend (struct proc* proc, struct proc_suspension_q* sq, spin_lock_t* resource_lock,
spin_lock_ctx_t* ctxrl, struct cpu** reschedule_cpu) {
spin_lock_ctx_t ctxpr, ctxcpu, ctxsq;
struct cpu** reschedule_cpu) {
struct cpu* cpu = proc->cpu;
struct proc_sq_entry* sq_entry = malloc (sizeof (*sq_entry));
if (!sq_entry) {
spin_unlock (resource_lock, ctxrl);
spin_unlock (resource_lock);
return PROC_NO_RESCHEDULE;
}
sq_entry->proc = proc;
sq_entry->sq = sq;
spin_lock (&cpu->lock, &ctxcpu);
spin_lock (&proc->lock, &ctxpr);
spin_lock (&sq->lock, &ctxsq);
spin_lock (&cpu->lock);
spin_lock (&proc->lock);
spin_lock (&sq->lock);
spin_unlock (resource_lock, ctxrl);
spin_unlock (resource_lock);
atomic_store (&proc->state, PROC_SUSPENDED);
@@ -44,9 +43,9 @@ bool proc_sq_suspend (struct proc* proc, struct proc_suspension_q* sq, spin_lock
proc->cpu = NULL;
spin_unlock (&sq->lock, &ctxsq);
spin_unlock (&proc->lock, &ctxpr);
spin_unlock (&cpu->lock, &ctxcpu);
spin_unlock (&sq->lock);
spin_unlock (&proc->lock);
spin_unlock (&cpu->lock);
*reschedule_cpu = cpu;
@@ -55,13 +54,12 @@ bool proc_sq_suspend (struct proc* proc, struct proc_suspension_q* sq, spin_lock
bool proc_sq_resume (struct proc* proc, struct proc_sq_entry* sq_entry,
struct cpu** reschedule_cpu) {
spin_lock_ctx_t ctxsq, ctxpr, ctxcpu;
struct cpu* cpu = cpu_find_lightest ();
struct proc_suspension_q* sq = sq_entry->sq;
spin_lock (&cpu->lock, &ctxcpu);
spin_lock (&proc->lock, &ctxpr);
spin_lock (&sq->lock, &ctxsq);
spin_lock (&cpu->lock);
spin_lock (&proc->lock);
spin_lock (&sq->lock);
/* remove from sq's list */
list_remove (sq->proc_list, &sq_entry->sq_link);
@@ -77,9 +75,9 @@ bool proc_sq_resume (struct proc* proc, struct proc_sq_entry* sq_entry,
list_append (cpu->proc_run_q, &proc->cpu_run_q_link);
atomic_fetch_add (&cpu->proc_run_q_count, 1);
spin_unlock (&sq->lock, &ctxsq);
spin_unlock (&proc->lock, &ctxpr);
spin_unlock (&cpu->lock, &ctxcpu);
spin_unlock (&sq->lock);
spin_unlock (&proc->lock);
spin_unlock (&cpu->lock);
free (sq_entry);
@@ -89,9 +87,7 @@ bool proc_sq_resume (struct proc* proc, struct proc_sq_entry* sq_entry,
}
void proc_sqs_cleanup (struct proc* proc) {
spin_lock_ctx_t ctxsq, ctxpr;
spin_lock (&proc->lock, &ctxpr);
spin_lock (&proc->lock);
/* clean suspension queue entries */
struct list_node_link *sq_link, *sq_link_tmp;
@@ -99,7 +95,7 @@ void proc_sqs_cleanup (struct proc* proc) {
struct proc_sq_entry* sq_entry = list_entry (sq_link, struct proc_sq_entry, proc_link);
struct proc_suspension_q* sq = sq_entry->sq;
spin_lock (&sq->lock, &ctxsq);
spin_lock (&sq->lock);
/* remove from sq's list */
list_remove (sq->proc_list, &sq_entry->sq_link);
@@ -107,10 +103,10 @@ void proc_sqs_cleanup (struct proc* proc) {
/* remove from proc's list */
list_remove (proc->sq_entries, &sq_entry->proc_link);
spin_unlock (&sq->lock, &ctxsq);
spin_unlock (&sq->lock);
free (sq_entry);
}
spin_unlock (&proc->lock, &ctxpr);
spin_unlock (&proc->lock);
}