GBA: Make sure interrupting the thread actually pauses it

This commit is contained in:
Jeffrey Pfau 2014-11-27 00:06:49 -08:00
parent 22e7eff33c
commit 64ba9d2d8e
1 changed files with 16 additions and 14 deletions

View File

@ -180,6 +180,7 @@ static THREAD_ENTRY _GBAThreadRun(void* context) {
int resetScheduled = 0;
MutexLock(&threadContext->stateMutex);
while (threadContext->state > THREAD_RUNNING && threadContext->state < THREAD_EXITING) {
if (threadContext->state == THREAD_PAUSING) {
threadContext->state = THREAD_PAUSED;
ConditionWake(&threadContext->stateCond);
@ -192,9 +193,10 @@ static THREAD_ENTRY _GBAThreadRun(void* context) {
threadContext->state = THREAD_RUNNING;
resetScheduled = 1;
}
while (threadContext->state == THREAD_PAUSED) {
while (threadContext->state == THREAD_PAUSED || threadContext->state == THREAD_INTERRUPTED) {
ConditionWait(&threadContext->stateCond, &threadContext->stateMutex);
}
}
MutexUnlock(&threadContext->stateMutex);
if (resetScheduled) {
ARMReset(&cpu);