diff options
author | Anton Kling <anton@kling.gg> | 2024-02-16 18:28:14 +0100 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-02-16 18:28:14 +0100 |
commit | 413d09388bf33c658f3e71b18e4b069f18461393 (patch) | |
tree | 5df4e31367142bbf1c8285c51366f2d9398135ca /kernel/sched | |
parent | 3922adcdec5bd003b4106ffce79c28553bc40c15 (diff) |
General cleanup
Diffstat (limited to 'kernel/sched')
-rw-r--r-- | kernel/sched/scheduler.c | 34 | ||||
-rw-r--r-- | kernel/sched/scheduler.h | 8 |
2 files changed, 12 insertions, 30 deletions
diff --git a/kernel/sched/scheduler.c b/kernel/sched/scheduler.c index 505dbd8..9ed6552 100644 --- a/kernel/sched/scheduler.c +++ b/kernel/sched/scheduler.c @@ -53,37 +53,20 @@ void process_push_signal(process_t *p, signal_t s) { p = current_task; } - int index = -1; - for (int i = 0; i < 100; i++) { - const signal_t *s = p->active_signals[i]; - if (!s) { - index = i; - break; - } - } - if (-1 == index) { - assert(0); - return; + if (p->is_halted) { + p->is_interrupted = 1; } + signal_t *new_signal_entry = kmalloc(sizeof(signal_t)); memcpy(new_signal_entry, &s, sizeof(signal_t)); - p->active_signals[index] = new_signal_entry; + stack_push(&p->signal_stack, new_signal_entry); } const signal_t *process_pop_signal(process_t *p) { if (!p) { p = current_task; } - - for (int i = 0; i < 100; i++) { - const signal_t *s = p->active_signals[i]; - if (!s) { - continue; - } - p->active_signals[i] = NULL; - return s; - } - return NULL; + return stack_pop(&p->signal_stack); } bool get_task_from_pid(u32 pid, process_t **out) { @@ -107,7 +90,6 @@ void set_signal_handler(int sig, void (*handler)(int)) { void insert_eip_on_stack(u32 cr3, u32 address, u32 value); process_t *create_process(process_t *p, u32 esp, u32 eip) { - kprintf("CREATE_PROCESS\n"); process_t *r; r = kcalloc(1, sizeof(process_t)); r->dead = 0; @@ -115,6 +97,8 @@ process_t *create_process(process_t *p, u32 esp, u32 eip) { r->esp = r->ebp = 0; r->eip = 0; r->sleep_until = 0; + r->is_interrupted = 0; + r->is_halted = 0; if (!p) { assert(1 == next_pid); strncpy(r->program_name, "[kernel]", sizeof(current_task->program_name)); @@ -132,9 +116,6 @@ process_t *create_process(process_t *p, u32 esp, u32 eip) { r->interrupt_handler = NULL; r->tcb = kcalloc(1, sizeof(struct TCB)); - kprintf("r->tcb: %x\n", r->tcb); - kprintf("r->cr3: %x\n", r->cr3); - kprintf("p: %x\n", p); r->tcb->CR3 = r->cr3->physical_address; // Temporarily switch to the page directory to be able to place the @@ -209,6 +190,7 @@ void tasking_init(void) { int i = 0; void free_process(void) { + kprintf("pid: %x\n", get_current_task()->pid); kprintf("Exiting process: %s\n", get_current_task()->program_name); // free_process() will purge all contents such as allocated frames // out of the current process. This will be called by exit() and diff --git a/kernel/sched/scheduler.h b/kernel/sched/scheduler.h index f73d8ef..03f4710 100644 --- a/kernel/sched/scheduler.h +++ b/kernel/sched/scheduler.h @@ -68,11 +68,8 @@ struct Process { vfs_inode_t *write_halt_inode[100]; vfs_inode_t *disconnect_halt_inode[100]; - // // FIXME: Make this a array or circular buffer - // reg_t restore_context; struct stack restore_context_stack; - - signal_t *active_signals[100]; + struct stack signal_stack; u32 halts[2]; struct Halt *halt_list; @@ -82,6 +79,9 @@ struct Process { TCB *tcb; + int is_interrupted; + int is_halted; + // TODO: Create a linkedlist of childs so that the parent process // can do stuff such as reap zombies and get status. process_t *child; |