diff options
| author | Ada Christine <adachristine18@gmail.com> | 2022-02-14 00:33:18 +0000 |
|---|---|---|
| committer | Ada Christine <adachristine18@gmail.com> | 2022-02-14 00:33:18 +0000 |
| commit | 86de700207fb0114ec52fafc36f84e1cbe508fd8 (patch) | |
| tree | 830649e3b7081e4c43d579a6ded67f7ee18add92 /kc/core/task.c | |
| parent | e8a76b2f6b53d99640ceb2850bf4e45118b923f1 (diff) | |
entering idle loop works with timer
Diffstat (limited to 'kc/core/task.c')
| -rw-r--r-- | kc/core/task.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/kc/core/task.c b/kc/core/task.c index b825f01..b381793 100644 --- a/kc/core/task.c +++ b/kc/core/task.c @@ -42,10 +42,13 @@ static void lock_scheduler(void) static void unlock_scheduler(void) { - if (1 == schedule_lock_cnt) + if (schedule_lock_cnt >= 1) { schedule_lock_cnt--; - __asm__ volatile("sti;"); + } + if (schedule_lock_cnt == 0) + { + __asm__ volatile ("sti;"); } } @@ -86,6 +89,7 @@ static void idle_task_thread(void) noreturn void task_init(void) { + lock_scheduler(); char *kernel_rsp0 = vm_alloc(4096); // TODO: make it so this isn't demand-allocated. kernel_rsp0[1] = 0; @@ -95,12 +99,13 @@ noreturn void task_init(void) (struct kc_thread *)(first_task + 16384 - sizeof(*idle_thread)); idle_thread->state.stack = (uintptr_t)idle_thread; idle_thread->state.stack_top = (uintptr_t)kernel_rsp0; - + __asm__ volatile ( "mov %%cr3, %%rax\n\t" "mov %%rax, 0(%%rsi)\n\t" "mov %%rcx, %%rsp\n\t" + "call unlock_scheduler\n\t" "jmp idle_task_thread\n\t" : "=m"(idle_thread->state.page_map) : "S"(&idle_thread->state.page_map), |
