aboutsummaryrefslogtreecommitdiff
path: root/kernel/features/proc.c
diff options
context:
space:
mode:
authorMarvin Borner2021-01-14 00:18:44 +0100
committerMarvin Borner2021-01-14 00:18:44 +0100
commit388b3fa1bd8af8c5df6aef8447ffd2a8b2cb9300 (patch)
tree2effeb407e96f4e43dc5332346c6f9d378f9b8ef /kernel/features/proc.c
parent91abed9333241731d0cd877beba4e2d4675989c8 (diff)
Added kernel idle process
Diffstat (limited to 'kernel/features/proc.c')
-rw-r--r--kernel/features/proc.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index 8fbb4c5..f792824 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -16,6 +16,7 @@ u32 current_pid = 0;
u32 quantum = 0;
struct proc *priority_proc;
struct list *proc_list;
+struct node *idle_proc;
struct node *current;
// TODO: Use less memcpy and only copy relevant registers
@@ -44,12 +45,7 @@ void scheduler(struct regs *regs)
} else if (((struct proc *)proc_list->head->data)->state == PROC_RUNNING) {
current = proc_list->head;
} else {
- /* sti(); */
- /* hlt(); */
- /* cli(); */
- //print("TODO: All processes are sleeping!\n"); // TODO!
- //loop();
- return;
+ current = idle_proc;
}
memcpy(regs, &((struct proc *)current->data)->regs, sizeof(struct regs));
@@ -67,6 +63,12 @@ void scheduler(struct regs *regs)
/* printf("{%d}", ((struct proc *)current->data)->pid); */
}
+void kernel_idle()
+{
+ while (1)
+ ;
+}
+
void proc_print(void)
{
struct node *node = proc_list->head;
@@ -247,7 +249,13 @@ void proc_init(void)
device_add(dev);
vfs_mount(dev, "/proc/");
- kernel_proc = proc_make();
+ // Idle proc
+ struct proc *kernel_proc = proc_make();
+ void (*func)() = kernel_idle;
+ proc_load(kernel_proc, *(void **)&func);
+ strcpy(kernel_proc->name, "idle");
+ kernel_proc->state = PROC_SLEEPING;
+ idle_proc = list_add(proc_list, kernel_proc);
struct node *new = list_add(proc_list, proc_make());
bin_load((char *)"/bin/init", new->data);