diff options
-rw-r--r-- | core/host/task.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/host/task.c b/core/host/task.c index 156aeeed62..e560b4c59d 100644 --- a/core/host/task.c +++ b/core/host/task.c @@ -121,12 +121,16 @@ int in_interrupt_context(void) void interrupt_disable(void) { + pthread_mutex_lock(&interrupt_lock); interrupt_disabled = 1; + pthread_mutex_unlock(&interrupt_lock); } void interrupt_enable(void) { + pthread_mutex_lock(&interrupt_lock); interrupt_disabled = 0; + pthread_mutex_unlock(&interrupt_lock); } static void _task_execute_isr(int sig) @@ -210,9 +214,11 @@ static void task_register_interrupt(void) void task_trigger_test_interrupt(void (*isr)(void)) { - if (interrupt_disabled) - return; pthread_mutex_lock(&interrupt_lock); + if (interrupt_disabled) { + pthread_mutex_unlock(&interrupt_lock); + return; + } /* Suspend current task and excute ISR */ pending_isr = isr; |