aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2020-05-11 23:36:08 +0200
committerMarvin Borner2020-05-11 23:36:08 +0200
commitfa5aa82470783d20621f3d21e419f5b8ce70ad0a (patch)
tree03b175f47f918bcea522a1da2ce82f754e0e64a5
parentfe4280eb69fbeb386b5442b3aeb515dde1c117ec (diff)
Fixed process name and added process tree print
-rw-r--r--src/kernel/interrupts/isr.c3
-rw-r--r--src/kernel/tasks/process.c16
-rw-r--r--src/kernel/tasks/process.h2
3 files changed, 19 insertions, 2 deletions
diff --git a/src/kernel/interrupts/isr.c b/src/kernel/interrupts/isr.c
index 8bfb7bd..1ad5f67 100644
--- a/src/kernel/interrupts/isr.c
+++ b/src/kernel/interrupts/isr.c
@@ -126,7 +126,8 @@ void fault_handler(struct regs *r)
}
if (current_proc != NULL) {
- warn("%s: Halting process %d", message, current_proc->pid);
+ warn("%s: Suspending process %s with ID %d", message, current_proc->name,
+ current_proc->pid);
memcpy(&current_proc->registers, r, sizeof(struct regs));
process_suspend(current_proc->pid);
process_force_switch(r);
diff --git a/src/kernel/tasks/process.c b/src/kernel/tasks/process.c
index a361355..2f45898 100644
--- a/src/kernel/tasks/process.c
+++ b/src/kernel/tasks/process.c
@@ -74,6 +74,21 @@ void process_init(struct process *proc)
userspace_enter(proc);
}
+// Only for debugging purposes
+void process_print_tree()
+{
+ serial_put('\n');
+ info("PROCESS TREE");
+ struct process *proc = root;
+
+ while (proc != NULL) {
+ info("%s with PID %d (state: %s)", proc->name, proc->pid,
+ proc->state == PROC_RUNNING ? "running" : "sleeping");
+ proc = proc->next;
+ }
+ serial_put('\n');
+}
+
u32 process_spawn(struct process *process)
{
debug("Spawning process %d", process->pid);
@@ -82,6 +97,7 @@ u32 process_spawn(struct process *process)
process->state = PROC_RUNNING;
process->parent = current_proc;
+ process_print_tree();
//process_suspend(current_proc->pid);
diff --git a/src/kernel/tasks/process.h b/src/kernel/tasks/process.h
index c015df9..b10c63c 100644
--- a/src/kernel/tasks/process.h
+++ b/src/kernel/tasks/process.h
@@ -18,7 +18,7 @@ struct process {
u32 pid;
u32 gid;
- char *name;
+ char name[256];
int state;
int thread;