summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic (Chun-Ju) Yang <victoryang@chromium.org>2014-01-08 15:28:53 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-01-08 16:39:34 +0000
commit10081abeb653a6fef4aa735a0f11a48d4d04dc67 (patch)
tree15084ce03103c5e7be30c4390cb8d71233c2fb20
parent61d2652ca4ea9667596cffd9a812c7a01eaf5fbe (diff)
downloadchrome-ec-10081abeb653a6fef4aa735a0f11a48d4d04dc67.tar.gz
emulator: Guard interrupt status with mutex lock
This prevents an interrupt from being triggered when we happen to be enabling/disabling global interrupt. BUG=chrome-os-partner:19235 TEST=Repeatedly run interrupt test BRANCH=None Change-Id: I0163aff801ddbcee4aedba7a78966d97336c79ca Signed-off-by: Vic (Chun-Ju) Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/181920 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--core/host/task.c10
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;