From 503f176e001ddf15e6e32bc912cf10b5764bc23b Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 4 Mar 2015 11:51:30 +0100 Subject: Process exiting & thread termination. IMPORTANT NOTE FOLLOWS. Threads may now communicate via wait_on(void* ressource) and resume_on (void* ressource). Previous pause() is replaced by wait_on(current_thread) and resume(thread) by resume_on(thread). wait_on(x) may return false, indicating that the reason for returning is NOT that resume_on(x) was called but something else happenned. Typically false indicates that the curent thread is being killed and must terminate its kernel-land processing as soon as possible. --- src/kernel/core/idt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/kernel/core/idt.c') diff --git a/src/kernel/core/idt.c b/src/kernel/core/idt.c index 5c77502..fcf8074 100644 --- a/src/kernel/core/idt.c +++ b/src/kernel/core/idt.c @@ -103,6 +103,11 @@ void idt_ex_handler(registers_t *regs) { current_thread->user_ex_handler(regs); } } + + // maybe exit + if (current_thread != 0 && regs->eip < K_HIGHHALF_ADDR && current_thread->must_exit) { + exit(); + } } /* Called in interrupt.s when an IRQ fires (interrupt 32 to 47) */ @@ -120,11 +125,21 @@ void idt_irq_handler(registers_t *regs) { } exit_critical(st); + + // maybe exit + if (current_thread != 0 && regs->eip < K_HIGHHALF_ADDR && current_thread->must_exit) { + exit(); + } } /* Caled in interrupt.s when a syscall is called */ void idt_syscall_handler(registers_t *regs) { syscall_handler(regs); + + // maybe exit + if (current_thread != 0 && regs->eip < K_HIGHHALF_ADDR && current_thread->must_exit) { + exit(); + } } /* For internal use only. Sets up an entry of the IDT with given parameters. */ -- cgit v1.2.3