aboutsummaryrefslogtreecommitdiff
path: root/kernel/features/proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/features/proc.c')
-rw-r--r--kernel/features/proc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index 76f552b..ffe0af0 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -36,14 +36,18 @@ void scheduler(struct regs *regs)
if (current)
memcpy(&((struct proc *)current->data)->regs, regs, sizeof(struct regs));
- if (priority_proc) {
+ if (priority_proc && priority_proc->state == PROC_RUNNING) {
current = list_first_data(proc_list, priority_proc);
priority_proc = NULL;
assert(current);
- } else if (current && current->next) {
+ } else if (current && current->next &&
+ ((struct proc *)current->next->data)->state == PROC_RUNNING) {
current = current->next;
- } else {
+ } else if (((struct proc *)proc_list->head->data)->state == PROC_RUNNING) {
current = proc_list->head;
+ } else {
+ print("TODO: All processes are sleeping!\n"); // TODO!
+ /* loop(); */
}
memcpy(regs, &((struct proc *)current->data)->regs, sizeof(struct regs));