Implement waiting for process, CE add command cancelation, rctx many cpus
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m27s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m27s
This commit is contained in:
@@ -198,10 +198,7 @@ void proc_register (struct proc* proc, struct cpu* register_cpu, struct reschedu
|
||||
spin_unlock (&cpu->lock);
|
||||
spin_unlock (&proc_tree_lock);
|
||||
|
||||
if (rctx != NULL) {
|
||||
rctx->reschedule = true;
|
||||
rctx->cpu = cpu;
|
||||
}
|
||||
rctx_insert_cpu (rctx, cpu);
|
||||
}
|
||||
|
||||
/* caller holds cpu->lock */
|
||||
@@ -225,11 +222,15 @@ static struct proc* proc_find_sched (struct cpu* cpu) {
|
||||
struct proc* proc = list_entry (current, struct proc, cpu_run_q_link);
|
||||
|
||||
spin_lock (&proc->lock);
|
||||
int state = proc->state;
|
||||
spin_unlock (&proc->lock);
|
||||
|
||||
if (state == PROC_READY)
|
||||
int state = proc->state;
|
||||
|
||||
if (state == PROC_READY) {
|
||||
spin_unlock (&proc->lock);
|
||||
return proc;
|
||||
}
|
||||
|
||||
spin_unlock (&proc->lock);
|
||||
|
||||
current = current->next ? current->next : cpu->proc_run_q;
|
||||
} while (current != start);
|
||||
@@ -278,7 +279,7 @@ static void proc_reap (struct reschedule_ctx* rctx) {
|
||||
|
||||
void proc_sched (void) {
|
||||
int s_cycles = atomic_fetch_add (&sched_cycles, 1);
|
||||
struct reschedule_ctx rctx = {.reschedule = false, .cpu = NULL};
|
||||
struct reschedule_ctx rctx = {0};
|
||||
|
||||
if (s_cycles % SCHED_REAP_FREQ == 0)
|
||||
proc_reap (&rctx);
|
||||
@@ -321,14 +322,24 @@ void proc_kill (struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&cpu->lock);
|
||||
|
||||
rctx->reschedule = true;
|
||||
rctx->cpu = cpu;
|
||||
rctx_insert_cpu (rctx, cpu);
|
||||
|
||||
DEBUG ("killed PID %d\n", proc->pid);
|
||||
}
|
||||
|
||||
void proc_wait_for (struct proc* proc, struct reschedule_ctx* rctx, struct proc* wait_proc) {
|
||||
proc_sq_suspend (proc, &wait_proc->done_sq, NULL, rctx);
|
||||
}
|
||||
|
||||
static void proc_irq_sched (void* arg, void* regs, struct reschedule_ctx* rctx) {
|
||||
(void)arg, (void)regs;
|
||||
|
||||
#if defined(__x86_64__)
|
||||
struct saved_regs* sr = regs;
|
||||
if (sr->cs != (GDT_UCODE | 0x3))
|
||||
return;
|
||||
#endif
|
||||
|
||||
proc_sched ();
|
||||
}
|
||||
|
||||
@@ -338,14 +349,14 @@ void proc_init (void) {
|
||||
irq_attach (&proc_irq_sched, NULL, CPU_REQUEST_SCHED);
|
||||
#endif
|
||||
|
||||
struct reschedule_ctx rctx = {.cpu = NULL, .reschedule = false};
|
||||
struct reschedule_ctx rctx = {0};
|
||||
|
||||
struct proc* spin_proc = proc_from_file (VFS_KERNEL, "RD", "/spin", &rctx);
|
||||
proc_register (spin_proc, thiscpu, NULL);
|
||||
proc_register (spin_proc, thiscpu, &rctx);
|
||||
|
||||
struct proc* init = proc_from_file (VFS_KERNEL, "RD", "/init", &rctx);
|
||||
init->procgroup->capabilities |= (PROC_CAP_TERMINAL | PROC_CAP_KB);
|
||||
proc_register (init, thiscpu, NULL);
|
||||
proc_register (init, thiscpu, &rctx);
|
||||
|
||||
spin_lock (&spin_proc->cpu->lock);
|
||||
do_sched (spin_proc, &spin_proc->cpu->lock);
|
||||
|
||||
Reference in New Issue
Block a user