diff --git a/src/system/kernel/arch/arm/arch_int.cpp b/src/system/kernel/arch/arm/arch_int.cpp index bd6c2fe8cb..2e35243a9e 100644 --- a/src/system/kernel/arch/arm/arch_int.cpp +++ b/src/system/kernel/arch/arm/arch_int.cpp @@ -474,12 +474,7 @@ arch_arm_irq(struct iframe *iframe) Thread* thread = thread_get_current_thread(); cpu_status state = disable_interrupts(); - if (thread->cpu->invoke_scheduler) { - SpinLocker schedulerLocker(thread->scheduler_lock); - scheduler_reschedule(B_THREAD_READY); - schedulerLocker.Unlock(); - restore_interrupts(state); - } else if (thread->post_interrupt_callback != NULL) { + if (thread->post_interrupt_callback != NULL) { void (*callback)(void*) = thread->post_interrupt_callback; void* data = thread->post_interrupt_data; @@ -489,6 +484,11 @@ arch_arm_irq(struct iframe *iframe) restore_interrupts(state); callback(data); + } else if (thread->cpu->invoke_scheduler) { + SpinLocker schedulerLocker(thread->scheduler_lock); + scheduler_reschedule(B_THREAD_READY); + schedulerLocker.Unlock(); + restore_interrupts(state); } } diff --git a/src/system/kernel/arch/arm64/arch_int.cpp b/src/system/kernel/arch/arm64/arch_int.cpp index 2cfcea780e..afc3b4b938 100644 --- a/src/system/kernel/arch/arm64/arch_int.cpp +++ b/src/system/kernel/arch/arm64/arch_int.cpp @@ -181,12 +181,7 @@ after_exception() { Thread* thread = thread_get_current_thread(); cpu_status state = disable_interrupts(); - if (thread->cpu->invoke_scheduler) { - SpinLocker schedulerLocker(thread->scheduler_lock); - scheduler_reschedule(B_THREAD_READY); - schedulerLocker.Unlock(); - restore_interrupts(state); - } else if (thread->post_interrupt_callback != NULL) { + if (thread->post_interrupt_callback != NULL) { void (*callback)(void*) = thread->post_interrupt_callback; void* data = thread->post_interrupt_data; @@ -196,6 +191,11 @@ after_exception() restore_interrupts(state); callback(data); + } else if (thread->cpu->invoke_scheduler) { + SpinLocker schedulerLocker(thread->scheduler_lock); + scheduler_reschedule(B_THREAD_READY); + schedulerLocker.Unlock(); + restore_interrupts(state); } } diff --git a/src/system/kernel/arch/m68k/arch_int.cpp b/src/system/kernel/arch/m68k/arch_int.cpp index 2854046a0c..db40fbbba5 100644 --- a/src/system/kernel/arch/m68k/arch_int.cpp +++ b/src/system/kernel/arch/m68k/arch_int.cpp @@ -305,12 +305,7 @@ dprintf("handling I/O interrupts done\n"); } int state = disable_interrupts(); - if (thread->cpu->invoke_scheduler) { - SpinLocker schedulerLocker(thread->scheduler_lock); - scheduler_reschedule(B_THREAD_READY); - schedulerLocker.Unlock(); - restore_interrupts(state); - } else if (hardwareInterrupt && thread->post_interrupt_callback != NULL) { + if (hardwareInterrupt && thread->post_interrupt_callback != NULL) { void (*callback)(void*) = thread->post_interrupt_callback; void* data = thread->post_interrupt_data; @@ -320,6 +315,11 @@ dprintf("handling I/O interrupts done\n"); restore_interrupts(state); callback(data); + } else if (thread->cpu->invoke_scheduler) { + SpinLocker schedulerLocker(thread->scheduler_lock); + scheduler_reschedule(B_THREAD_READY); + schedulerLocker.Unlock(); + restore_interrupts(state); } // pop iframe diff --git a/src/system/kernel/arch/ppc/arch_int.cpp b/src/system/kernel/arch/ppc/arch_int.cpp index eb798d3dd3..d3b1186876 100644 --- a/src/system/kernel/arch/ppc/arch_int.cpp +++ b/src/system/kernel/arch/ppc/arch_int.cpp @@ -246,12 +246,7 @@ dprintf("handling I/O interrupts done\n"); } cpu_status state = disable_interrupts(); - if (thread->cpu->invoke_scheduler) { - SpinLocker schedulerLocker(thread->scheduler_lock); - scheduler_reschedule(B_THREAD_READY); - schedulerLocker.Unlock(); - restore_interrupts(state); - } else if (thread->post_interrupt_callback != NULL) { + if (thread->post_interrupt_callback != NULL) { void (*callback)(void*) = thread->post_interrupt_callback; void* data = thread->post_interrupt_data; @@ -261,6 +256,11 @@ dprintf("handling I/O interrupts done\n"); restore_interrupts(state); callback(data); + } else if (thread->cpu->invoke_scheduler) { + SpinLocker schedulerLocker(thread->scheduler_lock); + scheduler_reschedule(B_THREAD_READY); + schedulerLocker.Unlock(); + restore_interrupts(state); } // pop iframe diff --git a/src/system/kernel/arch/riscv64/arch_int.cpp b/src/system/kernel/arch/riscv64/arch_int.cpp index 1c487f3ccc..90d27d629f 100644 --- a/src/system/kernel/arch/riscv64/arch_int.cpp +++ b/src/system/kernel/arch/riscv64/arch_int.cpp @@ -286,12 +286,7 @@ AfterInterrupt() Thread* thread = thread_get_current_thread(); cpu_status state = disable_interrupts(); - if (thread->cpu->invoke_scheduler) { - SpinLocker schedulerLocker(thread->scheduler_lock); - scheduler_reschedule(B_THREAD_READY); - schedulerLocker.Unlock(); - restore_interrupts(state); - } else if (thread->post_interrupt_callback != NULL) { + if (thread->post_interrupt_callback != NULL) { void (*callback)(void*) = thread->post_interrupt_callback; void* data = thread->post_interrupt_data; @@ -301,6 +296,11 @@ AfterInterrupt() restore_interrupts(state); callback(data); + } else if (thread->cpu->invoke_scheduler) { + SpinLocker schedulerLocker(thread->scheduler_lock); + scheduler_reschedule(B_THREAD_READY); + schedulerLocker.Unlock(); + restore_interrupts(state); } } diff --git a/src/system/kernel/arch/x86/arch_int.cpp b/src/system/kernel/arch/x86/arch_int.cpp index ddbf84fef4..ef8ade9f12 100644 --- a/src/system/kernel/arch/x86/arch_int.cpp +++ b/src/system/kernel/arch/x86/arch_int.cpp @@ -241,12 +241,7 @@ x86_hardware_interrupt(struct iframe* frame) } cpu_status state = disable_interrupts(); - if (thread->cpu->invoke_scheduler) { - SpinLocker schedulerLocker(thread->scheduler_lock); - scheduler_reschedule(B_THREAD_READY); - schedulerLocker.Unlock(); - restore_interrupts(state); - } else if (thread->post_interrupt_callback != NULL) { + if (thread->post_interrupt_callback != NULL) { void (*callback)(void*) = thread->post_interrupt_callback; void* data = thread->post_interrupt_data; @@ -256,6 +251,11 @@ x86_hardware_interrupt(struct iframe* frame) restore_interrupts(state); callback(data); + } else if (thread->cpu->invoke_scheduler) { + SpinLocker schedulerLocker(thread->scheduler_lock); + scheduler_reschedule(B_THREAD_READY); + schedulerLocker.Unlock(); + restore_interrupts(state); } }