cpu->proc_current cannot be NULL
This commit is contained in:
@@ -12,12 +12,16 @@
|
||||
#include <sys/spin_lock.h>
|
||||
|
||||
void proc_mutexes_cleanup (struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
uint64_t fpg, fr;
|
||||
uint64_t fpg, fr, fp;
|
||||
|
||||
spin_lock (&proc->procgroup->lock, &fpg);
|
||||
spin_lock (&proc->lock, &fp);
|
||||
struct procgroup* procgroup = proc->procgroup;
|
||||
spin_unlock (&proc->lock, fp);
|
||||
|
||||
spin_lock (&procgroup->lock, &fpg);
|
||||
|
||||
struct rb_node_link* rnode;
|
||||
rbtree_first (&proc->procgroup->resource_tree, rnode);
|
||||
rbtree_first (&procgroup->resource_tree, rnode);
|
||||
|
||||
while (rnode) {
|
||||
struct rb_node_link* next;
|
||||
@@ -43,7 +47,7 @@ void proc_mutexes_cleanup (struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
spin_unlock (&resource->lock, fr);
|
||||
}
|
||||
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
spin_unlock (&procgroup->lock, fpg);
|
||||
}
|
||||
|
||||
void proc_cleanup_resource_mutex (struct proc_resource* resource, struct reschedule_ctx* rctx) {
|
||||
|
||||
@@ -234,7 +234,7 @@ static struct proc* proc_find_sched (struct cpu* cpu) {
|
||||
if (!cpu->proc_run_q)
|
||||
return NULL;
|
||||
|
||||
if (cpu->proc_current && cpu->proc_current->cpu_run_q_link.next)
|
||||
if (cpu->proc_current->cpu_run_q_link.next)
|
||||
current = cpu->proc_current->cpu_run_q_link.next;
|
||||
else
|
||||
current = cpu->proc_run_q;
|
||||
@@ -282,7 +282,6 @@ retry:
|
||||
else
|
||||
spin_unlock (&cpu->lock, fc);
|
||||
} else {
|
||||
cpu->proc_current = NULL;
|
||||
spin_unlock (&cpu->lock, fc);
|
||||
|
||||
spin_lock_relax ();
|
||||
@@ -310,8 +309,6 @@ void proc_kill (struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
|
||||
list_remove (cpu->proc_run_q, &proc->cpu_run_q_link);
|
||||
cpu->proc_run_q_count--;
|
||||
if (cpu->proc_current == proc)
|
||||
cpu->proc_current = NULL;
|
||||
|
||||
rbtree_delete (&proc_tree, &proc->proc_tree_link);
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ int proc_sq_suspend (struct proc* proc, struct proc_suspension_q* sq, spin_lock_
|
||||
uint64_t lockflags, struct reschedule_ctx* rctx) {
|
||||
uint64_t fc, fp, fsq;
|
||||
|
||||
spin_lock (&proc->lock, &fp);
|
||||
struct cpu* cpu = proc->cpu;
|
||||
spin_unlock (&proc->lock, fp);
|
||||
|
||||
struct proc_sq_entry* sq_entry = malloc (sizeof (*sq_entry));
|
||||
if (!sq_entry) {
|
||||
@@ -44,9 +46,6 @@ int proc_sq_suspend (struct proc* proc, struct proc_suspension_q* sq, spin_lock_
|
||||
list_remove (cpu->proc_run_q, &proc->cpu_run_q_link);
|
||||
cpu->proc_run_q_count--;
|
||||
|
||||
if (cpu->proc_current == proc)
|
||||
cpu->proc_current = NULL;
|
||||
|
||||
int state = proc->state;
|
||||
|
||||
spin_unlock (&sq->lock, fsq);
|
||||
@@ -81,8 +80,6 @@ int proc_sq_resume (struct proc* proc, struct proc_sq_entry* sq_entry,
|
||||
proc->state = PROC_READY;
|
||||
|
||||
list_append (cpu->proc_run_q, &proc->cpu_run_q_link);
|
||||
if (cpu->proc_current == NULL)
|
||||
cpu->proc_current = proc;
|
||||
cpu->proc_run_q_count++;
|
||||
|
||||
int state = proc->state;
|
||||
|
||||
Reference in New Issue
Block a user