Fix scheduler locking hierarchy
This commit is contained in:
@@ -346,51 +346,6 @@ void proc_kill (struct proc* proc) {
|
||||
cpu_request_sched (cpu);
|
||||
}
|
||||
|
||||
void proc_suspend (struct proc* proc, struct proc_suspension_q* sq) {
|
||||
spin_lock_ctx_t ctxpr, ctxcpu, ctxsq;
|
||||
struct cpu* cpu = proc->cpu;
|
||||
|
||||
spin_lock (&proc->lock, &ctxpr);
|
||||
atomic_store (&proc->state, PROC_SUSPENDED);
|
||||
proc->suspension_q = sq;
|
||||
spin_unlock (&proc->lock, &ctxpr);
|
||||
|
||||
/* remove from run q */
|
||||
spin_lock (&cpu->lock, &ctxcpu);
|
||||
|
||||
list_remove (cpu->proc_run_q, &proc->cpu_run_q_link);
|
||||
if (cpu->proc_current == proc)
|
||||
cpu->proc_current = NULL;
|
||||
spin_unlock (&cpu->lock, &ctxcpu);
|
||||
|
||||
spin_lock (&sq->lock, &ctxsq);
|
||||
list_append (sq->proc_list, &proc->suspension_link);
|
||||
spin_unlock (&sq->lock, &ctxsq);
|
||||
|
||||
cpu_request_sched (cpu);
|
||||
}
|
||||
|
||||
void proc_resume (struct proc* proc) {
|
||||
spin_lock_ctx_t ctxsq, ctxpr, ctxcpu;
|
||||
struct cpu* cpu = proc->cpu;
|
||||
struct proc_suspension_q* sq = proc->suspension_q;
|
||||
|
||||
spin_lock (&sq->lock, &ctxsq);
|
||||
list_remove (sq->proc_list, &proc->suspension_link);
|
||||
spin_unlock (&sq->lock, &ctxsq);
|
||||
|
||||
spin_lock (&proc->lock, &ctxpr);
|
||||
proc->suspension_q = NULL;
|
||||
atomic_store (&proc->state, PROC_READY);
|
||||
spin_unlock (&proc->lock, &ctxpr);
|
||||
|
||||
spin_lock (&cpu->lock, &ctxcpu);
|
||||
list_append (cpu->proc_run_q, &proc->cpu_run_q_link);
|
||||
spin_unlock (&cpu->lock, &ctxcpu);
|
||||
|
||||
cpu_request_sched (cpu);
|
||||
}
|
||||
|
||||
static void proc_irq_sched (void* arg, void* regs) {
|
||||
(void)arg;
|
||||
proc_sched (regs);
|
||||
|
||||
Reference in New Issue
Block a user