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:
@@ -238,51 +238,8 @@ static struct proc* proc_find_sched (struct cpu* cpu) {
|
||||
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) {
|
||||
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 cpu* cpu = thiscpu;
|
||||
@@ -322,6 +279,16 @@ void proc_kill (struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
spin_unlock (&proc->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);
|
||||
|
||||
DEBUG ("killed PID %d\n", proc->pid);
|
||||
|
||||
Reference in New Issue
Block a user