mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
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>
This commit is contained in:
committed by
chrome-internal-fetch
parent
61d2652ca4
commit
10081abeb6
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user