From 43433fde0bd127e7857379a2799f538b71796287 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 17 Mar 2018 10:32:12 +0000 Subject: Improvements to simulator IRQ detection. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11792 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- os/hal/ports/simulator/posix/hal_lld.c | 10 +++++----- os/hal/ports/simulator/win32/hal_lld.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'os') diff --git a/os/hal/ports/simulator/posix/hal_lld.c b/os/hal/ports/simulator/posix/hal_lld.c index 041986092..449fd8e98 100755 --- a/os/hal/ports/simulator/posix/hal_lld.c +++ b/os/hal/ports/simulator/posix/hal_lld.c @@ -70,19 +70,17 @@ void hal_lld_init(void) { */ void _sim_check_for_interrupts(void) { struct timeval tv; + bool int_occurred = false; #if HAL_USE_SERIAL if (sd_lld_interrupt_pending()) { - _dbg_check_lock(); - if (chSchIsPreemptionRequired()) - chSchDoReschedule(); - _dbg_check_unlock(); - return; + int_occured = true; } #endif gettimeofday(&tv, NULL); if (timercmp(&tv, &nextcnt, >=)) { + int_occurred = true; timeradd(&nextcnt, &tick, &nextcnt); CH_IRQ_PROLOGUE(); @@ -92,7 +90,9 @@ void _sim_check_for_interrupts(void) { chSysUnlockFromISR(); CH_IRQ_EPILOGUE(); + } + if (int_occurred) { _dbg_check_lock(); if (chSchIsPreemptionRequired()) chSchDoReschedule(); diff --git a/os/hal/ports/simulator/win32/hal_lld.c b/os/hal/ports/simulator/win32/hal_lld.c index 624ec5f4d..e00aab428 100644 --- a/os/hal/ports/simulator/win32/hal_lld.c +++ b/os/hal/ports/simulator/win32/hal_lld.c @@ -76,20 +76,18 @@ void hal_lld_init(void) { */ void _sim_check_for_interrupts(void) { LARGE_INTEGER n; + bool int_occurred = false; #if HAL_USE_SERIAL if (sd_lld_interrupt_pending()) { - _dbg_check_lock(); - if (chSchIsPreemptionRequired()) - chSchDoReschedule(); - _dbg_check_unlock(); - return; + int_occured = true; } #endif /* Interrupt Timer simulation (10ms interval).*/ QueryPerformanceCounter(&n); if (n.QuadPart > nextcnt.QuadPart) { + int_occured = true; nextcnt.QuadPart += slice.QuadPart; CH_IRQ_PROLOGUE(); @@ -99,7 +97,9 @@ void _sim_check_for_interrupts(void) { chSysUnlockFromISR(); CH_IRQ_EPILOGUE(); + } + if (int_occurred) { _dbg_check_lock(); if (chSchIsPreemptionRequired()) chSchDoReschedule(); -- cgit v1.2.3