diff options
author | Freya Murphy <freya@freyacat.org> | 2025-04-29 10:27:05 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-04-29 10:27:05 -0400 |
commit | a7079cf0f66f01434bf0860c3020bcdbcf267317 (patch) | |
tree | fc8a668c4d4e67b6531c0357a1214d2faeb4ae19 /kernel | |
parent | fmt (diff) | |
download | comus-a7079cf0f66f01434bf0860c3020bcdbcf267317.tar.gz comus-a7079cf0f66f01434bf0860c3020bcdbcf267317.tar.bz2 comus-a7079cf0f66f01434bf0860c3020bcdbcf267317.zip |
dispatch(): wait for a process to schedule
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/procs.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/kernel/procs.c b/kernel/procs.c index 5b03e73..1668bef 100644 --- a/kernel/procs.c +++ b/kernel/procs.c @@ -1,8 +1,9 @@ #include <comus/drivers/pit.h> +#include <comus/memory.h> #include <comus/procs.h> #include <comus/error.h> #include <comus/cpu.h> -#include <comus/memory.h> +#include <comus/asm.h> #define PCB_QUEUE_EMPTY(q) ((q)->head == NULL) @@ -467,11 +468,17 @@ void schedule(struct pcb *pcb) __attribute__((noreturn)) void dispatch(void) { + int status; + assert(current_pcb == NULL, "dispatch: current process is not null"); - int status = pcb_queue_pop(ready, ¤t_pcb); - if (status != SUCCESS) - panic("dispatch queue remove failed, code %d", status); + // wait for a process to schedule + do { + status = pcb_queue_pop(ready, ¤t_pcb); + if (status == SUCCESS) + break; + int_wait(); + } while (1); // set the process up for success current_pcb->regs.cr3 = (uint64_t)mem_ctx_pgdir(current_pcb->memctx); |