X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fkern%2Firq.c;h=9a1ff514cef875e2aa426cd31134ffd7274e7df0;hb=b94d14d668b87c1e6f6ddad5b6aafd6b45a613b6;hp=23d19afac0ea76fb14abac4e87170822eb714807;hpb=3b33eb4b36445ee045f4cbac27f9331988205467;p=bertos.git diff --git a/bertos/kern/irq.c b/bertos/kern/irq.c index 23d19afa..9a1ff514 100644 --- a/bertos/kern/irq.c +++ b/bertos/kern/irq.c @@ -33,11 +33,16 @@ * * \version $Id: proc.h 1646 2008-08-17 13:49:48Z bernie $ * \author Bernie Innocenti + * + * Still in development, disable nightly test for now + * notest: avr + * notest: arm */ #include "irq.h" #include #include +#include #include @@ -52,34 +57,31 @@ static void (*irq_handlers[100])(void); /* signal handler */ void irq_entry(int signum) { +#if CONFIG_KERN_PREEMPT Process * const old_process = CurrentProcess; +#endif irq_handlers[signum](); #if CONFIG_KERN_PREEMPT - if (!CurrentProcess) + ASSERT2(CurrentProcess, "no idle proc?"); + + if (old_process != CurrentProcess) { - TRACEMSG("no runnable processes!"); + IRQ_DISABLE; + + TRACEMSG("switching from %p:%s to %p:%s", + old_process, old_process ? old_process->monitor.name : "---", + CurrentProcess, proc_currentName()); + + if (old_process) + swapcontext(&old_process->context, &CurrentProcess->context); + else + setcontext(&CurrentProcess->context); + IRQ_ENABLE; - pause(); - } - else - { - if (old_process != CurrentProcess) - { - TRACEMSG("switching from %p:%s to %p:%s", - old_process, old_process ? old_process->monitor.name : "-", - CurrentProcess, CurrentProcess->monitor.name); - - if (old_process) - swapcontext(&old_process->context, &CurrentProcess->context); - else - setcontext(&CurrentProcess->context); - - // not reached - } - TRACEMSG("keeping %p:%s", CurrentProcess, CurrentProcess->monitor.name); } + TRACEMSG("resuming %p:%s", CurrentProcess, CurrentProcess->monitor.name); #endif // CONFIG_KERN_PREEMPT } @@ -91,15 +93,14 @@ void irq_register(int irq, void (*callback)(void)) void irq_init(void) { struct sigaction act; + act.sa_handler = irq_entry; sigemptyset(&act.sa_mask); //sigaddset(&act.sa_mask, irq); act.sa_flags = SA_RESTART; // | SA_SIGINFO; sigaction(SIGUSR1, &act, NULL); - #if !(ARCH & ARCH_QT) - sigaction(SIGALRM, &act, NULL); - #endif + sigaction(SIGALRM, &act, NULL); MOD_INIT(irq); }