Fix checking if cpu->proc_current != NULL
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m37s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m37s
This commit is contained in:
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
qemu-system-x86_64 -M q35 -m 4G -serial stdio -enable-kvm -cdrom mop3.iso -smp 1 $@
|
qemu-system-x86_64 -M q35 -m 4G -serial stdio -enable-kvm -cdrom mop3.iso -smp 4 $@
|
||||||
|
|||||||
@@ -190,12 +190,15 @@ void intr_handler (void* stack_ptr) {
|
|||||||
intr_exception (regs);
|
intr_exception (regs);
|
||||||
} else {
|
} else {
|
||||||
spin_lock (&thiscpu->lock);
|
spin_lock (&thiscpu->lock);
|
||||||
|
|
||||||
struct proc* proc_current = thiscpu->proc_current;
|
struct proc* proc_current = thiscpu->proc_current;
|
||||||
|
|
||||||
|
if (proc_current != NULL) {
|
||||||
spin_lock (&proc_current->lock);
|
spin_lock (&proc_current->lock);
|
||||||
|
|
||||||
memcpy (&proc_current->pdata.regs, regs, sizeof (struct saved_regs));
|
memcpy (&proc_current->pdata.regs, regs, sizeof (struct saved_regs));
|
||||||
|
|
||||||
spin_unlock (&proc_current->lock);
|
spin_unlock (&proc_current->lock);
|
||||||
|
}
|
||||||
|
|
||||||
spin_unlock (&thiscpu->lock);
|
spin_unlock (&thiscpu->lock);
|
||||||
|
|
||||||
lapic_eoi ();
|
lapic_eoi ();
|
||||||
|
|||||||
@@ -238,51 +238,8 @@ static struct proc* proc_find_sched (struct cpu* cpu) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void proc_reap (struct reschedule_ctx* rctx) {
|
|
||||||
struct proc* proc = NULL;
|
|
||||||
struct list_node_link* reap_list = NULL;
|
|
||||||
|
|
||||||
spin_lock (&proc_tree_lock);
|
|
||||||
|
|
||||||
struct rb_node_link* node;
|
|
||||||
rbtree_first (&proc_tree, node);
|
|
||||||
|
|
||||||
while (node) {
|
|
||||||
struct rb_node_link* next;
|
|
||||||
rbtree_next (node, next);
|
|
||||||
proc = rbtree_entry (node, struct proc, proc_tree_link);
|
|
||||||
|
|
||||||
node = next;
|
|
||||||
|
|
||||||
spin_lock (&proc->lock);
|
|
||||||
|
|
||||||
if (proc->state == PROC_DEAD) {
|
|
||||||
list_append (reap_list, &proc->reap_link);
|
|
||||||
rbtree_delete (&proc_tree, &proc->proc_tree_link);
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_unlock (&proc->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_unlock (&proc_tree_lock);
|
|
||||||
|
|
||||||
struct list_node_link *reap_link, *reap_link_tmp;
|
|
||||||
list_foreach (reap_list, reap_link, reap_link_tmp) {
|
|
||||||
proc = list_entry (reap_link, struct proc, reap_link);
|
|
||||||
|
|
||||||
list_remove (reap_list, &proc->reap_link);
|
|
||||||
|
|
||||||
DEBUG ("cleanup PID %d\n", proc->pid);
|
|
||||||
proc_cleanup (proc, rctx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void proc_sched (void) {
|
void proc_sched (void) {
|
||||||
int s_cycles = atomic_fetch_add (&sched_cycles, 1);
|
int s_cycles = atomic_fetch_add (&sched_cycles, 1);
|
||||||
struct reschedule_ctx rctx = {0};
|
|
||||||
|
|
||||||
if (s_cycles % SCHED_REAP_FREQ == 0)
|
|
||||||
proc_reap (&rctx);
|
|
||||||
|
|
||||||
struct proc* next = NULL;
|
struct proc* next = NULL;
|
||||||
struct cpu* cpu = thiscpu;
|
struct cpu* cpu = thiscpu;
|
||||||
@@ -322,6 +279,16 @@ void proc_kill (struct proc* proc, struct reschedule_ctx* rctx) {
|
|||||||
spin_unlock (&proc->lock);
|
spin_unlock (&proc->lock);
|
||||||
spin_unlock (&cpu->lock);
|
spin_unlock (&cpu->lock);
|
||||||
|
|
||||||
|
spin_lock (&proc_tree_lock);
|
||||||
|
spin_lock (&proc->lock);
|
||||||
|
|
||||||
|
rbtree_delete (&proc_tree, &proc->proc_tree_link);
|
||||||
|
|
||||||
|
spin_unlock (&proc->lock);
|
||||||
|
spin_unlock (&proc_tree_lock);
|
||||||
|
|
||||||
|
proc_cleanup (proc, rctx);
|
||||||
|
|
||||||
rctx_insert_cpu (rctx, cpu);
|
rctx_insert_cpu (rctx, cpu);
|
||||||
|
|
||||||
DEBUG ("killed PID %d\n", proc->pid);
|
DEBUG ("killed PID %d\n", proc->pid);
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ struct proc {
|
|||||||
struct rb_node_link proc_tree_link;
|
struct rb_node_link proc_tree_link;
|
||||||
struct rb_node_link procgroup_memb_tree_link;
|
struct rb_node_link procgroup_memb_tree_link;
|
||||||
struct list_node_link cpu_run_q_link;
|
struct list_node_link cpu_run_q_link;
|
||||||
struct list_node_link reap_link;
|
|
||||||
struct list_node_link* sq_entries;
|
struct list_node_link* sq_entries;
|
||||||
struct procgroup* procgroup;
|
struct procgroup* procgroup;
|
||||||
struct proc_platformdata pdata;
|
struct proc_platformdata pdata;
|
||||||
|
|||||||
Reference in New Issue
Block a user