diff options
Diffstat (limited to 'kernel/features/proc.c')
-rw-r--r-- | kernel/features/proc.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/kernel/features/proc.c b/kernel/features/proc.c index d1a2780..1c0b443 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -17,8 +17,11 @@ u32 quantum = 0; struct list *proc_list; struct node *current; +// TODO: Use less memcpy and only copy relevant registers void scheduler(struct regs *regs) { + timer_handler(); + if (quantum == 0) { quantum = PROC_QUANTUM; } else { @@ -34,8 +37,6 @@ void scheduler(struct regs *regs) if (current) memcpy(&((struct proc *)current->data)->regs, regs, sizeof(struct regs)); - timer_handler(); - if (current && current->next) current = current->next; else @@ -71,9 +72,9 @@ void scheduler(struct regs *regs) quantum = PROC_QUANTUM; proc->state = PROC_IN_EVENT; - list_remove(proc->events, proc->events->head); regs->useresp += 4; ((u32 *)regs->useresp)[1] = (u32)proc_event->data; // Huh + list_remove(proc->events, proc->events->head); } /* printf("{%d}", ((struct proc *)current->data)->pid); */ @@ -158,6 +159,12 @@ void proc_exit(struct proc *proc, int status) hlt(); } +// TODO: More instant yield +void proc_yield() +{ + quantum = 0; +} + struct proc *proc_make() { struct proc *proc = malloc(sizeof(*proc)); |