Handle continous jobs via new subsystem - CJob
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
#include "intr/pic.h"
|
||||
#include "vmm/vmm.h"
|
||||
#include "proc/switch.h"
|
||||
#include "cjob/cjob.h"
|
||||
#include "elf.h"
|
||||
#include "errors.h"
|
||||
#include "kprintf.h"
|
||||
@ -174,7 +175,33 @@ Proc *proc_nextready(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void proc_reaper(void) {
|
||||
void proc_sched(void *cpustate) {
|
||||
intr_disable();
|
||||
|
||||
memcpy(&PROCS.current->platformdata.trapframe, cpustate, sizeof(IntrStackFrame));
|
||||
|
||||
PROCS.current = proc_nextready();
|
||||
|
||||
cjob_runjobs();
|
||||
|
||||
tss.rsp0 = (uint64_t)VIRT(PROCS.current->platformdata.kstack);
|
||||
proc_switch(&PROCS.current->platformdata.trapframe, (void *)PROCS.current->platformdata.cr3);
|
||||
}
|
||||
|
||||
void proc_kill(Proc *proc) {
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
proc->state = PROC_ZOMBIE;
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
}
|
||||
|
||||
void proc_killself(void) {
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
proc_kill(proc);
|
||||
}
|
||||
|
||||
void proc_gc_cjob(void *arg) {
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *head, *tmp;
|
||||
LL_FOREACH_SAFE(PROCS.procs, head, tmp) {
|
||||
@ -222,41 +249,12 @@ void proc_reaper(void) {
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
}
|
||||
|
||||
void proc_tick(void) {
|
||||
proc_reaper();
|
||||
ipc_mbustick();
|
||||
}
|
||||
|
||||
void proc_sched(void *cpustate) {
|
||||
intr_disable();
|
||||
|
||||
memcpy(&PROCS.current->platformdata.trapframe, cpustate, sizeof(IntrStackFrame));
|
||||
|
||||
PROCS.current = proc_nextready();
|
||||
|
||||
proc_tick();
|
||||
|
||||
tss.rsp0 = (uint64_t)VIRT(PROCS.current->platformdata.kstack);
|
||||
proc_switch(&PROCS.current->platformdata.trapframe, (void *)PROCS.current->platformdata.cr3);
|
||||
}
|
||||
|
||||
void proc_kill(Proc *proc) {
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
proc->state = PROC_ZOMBIE;
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
}
|
||||
|
||||
void proc_killself(void) {
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
proc_kill(proc);
|
||||
}
|
||||
|
||||
void proc_init(void) {
|
||||
spinlock_init(&PROCS.spinlock);
|
||||
PROCS.procs = NULL;
|
||||
|
||||
cjob_register(&proc_gc_cjob, NULL);
|
||||
|
||||
Proc *init = proc_spawnuser("base", "/bin/init");
|
||||
PROCS.current = init;
|
||||
proc_register(init);
|
||||
|
||||
Reference in New Issue
Block a user