Skip to content

Commit

Permalink
sch: Make sch_invoke return back to kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
marv7000 committed Nov 20, 2024
1 parent 19e33f6 commit 1010a04
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/menix/system/sch/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void sch_init(BootInfo* info);

// Makes the scheduler act immediately instead of waiting for a timer.
// ? Defined per architecture.
ATTR(noreturn) void sch_invoke();
void sch_invoke();

// Saves the architecture dependent data of the `thread`.
// ? Defined per architecture.
Expand Down
4 changes: 1 addition & 3 deletions kernel/arch/x86_64/sch/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@

#include <apic.h>

ATTR(noreturn) void sch_invoke()
void sch_invoke()
{
asm_interrupt_enable();

// Force a software interrupt.
asm_int(INT_TIMER);

__builtin_unreachable();
}

void sch_arch_save(Cpu* core, Thread* thread)
Expand Down
7 changes: 3 additions & 4 deletions kernel/arch/x86_64/system/interrupts.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,12 @@ void interrupt_register(usize idx, InterruptFn handler)
asm_interrupt_enable();
}

void interrupt_handler(Context* regs)
Context* interrupt_handler(Context* regs)
{
// If we have a handler for this interrupt, call it.
if (regs->isr < ARRAY_SIZE(exception_handlers) && exception_handlers[regs->isr])
{
exception_handlers[regs->isr](regs);
return;
return exception_handlers[regs->isr](regs);
}

// If unhandled and caused by the user, terminate the process with SIGILL.
Expand All @@ -118,7 +117,7 @@ void interrupt_handler(Context* regs)
arch_dump_registers(regs);

proc_kill(proc, true);
return;
return regs;
}

// Disable spinlocks so we have a chance of displaying a message.
Expand Down
2 changes: 1 addition & 1 deletion kernel/system/sch/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ Context* sch_reschedule(Context* context)
}

// Grab the next thread.
running = sch_next(running);
running = sch_next(thread_list);

// If there are no more threads to run, something went wrong.
if (running == NULL)
Expand Down
3 changes: 1 addition & 2 deletions kernel/system/sch/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ bool proc_execve(const char* name, const char* path, char** argv, char** envp, b
vm_set_page_map(map);
spin_free(&proc_lock);

// Run the scheduler.
sch_invoke();
return true;
}

usize proc_fork(Process* proc, Thread* thread)
Expand Down

0 comments on commit 1010a04

Please sign in to comment.