all repos — mgba @ a0a38caabee69d143d926192d4a3ab6fae6ac2e0

mGBA Game Boy Advance Emulator

PSP2: More threading improvements
Jeffrey Pfau jeffrey@endrift.com
Sun, 05 Jul 2015 21:22:54 -0700
commit

a0a38caabee69d143d926192d4a3ab6fae6ac2e0

parent

2ae4030c19f0b15d7e68d58a7a07ac7260d681eb

1 files changed, 18 insertions(+), 6 deletions(-)

jump to
M src/platform/psp2/threading.hsrc/platform/psp2/threading.h

@@ -59,17 +59,26 @@ return sceKernelDeleteSema(cond->semaphore);

} static inline int ConditionWait(Condition* cond, Mutex* mutex) { - MutexLock(&cond->mutex); + int ret = MutexLock(&cond->mutex); + if (ret < 0) { + return ret; + } ++cond->waiting; MutexUnlock(mutex); MutexUnlock(&cond->mutex); - sceKernelWaitSema(cond->semaphore, 1, 0); + ret = sceKernelWaitSema(cond->semaphore, 1, 0); + if (ret < 0) { + printf("Premature wakeup: %08X", ret); + } MutexLock(mutex); - return 0; + return ret; } static inline int ConditionWaitTimed(Condition* cond, Mutex* mutex, int32_t timeoutMs) { - MutexLock(&cond->mutex); + int ret = MutexLock(&cond->mutex); + if (ret < 0) { + return ret; + } ++cond->waiting; MutexUnlock(mutex); MutexUnlock(&cond->mutex);

@@ -77,7 +86,10 @@ SceUInt timeout = 0;

if (timeoutMs > 0) { timeout = timeoutMs; } - int ret = sceKernelWaitSema(cond->semaphore, 1, &timeout); + ret = sceKernelWaitSema(cond->semaphore, 1, &timeout); + if (ret < 0) { + printf("Premature wakeup: %08X", ret); + } MutexLock(mutex); return ret; }

@@ -104,7 +116,7 @@ return arg->entry(arg->context);

} static inline int ThreadCreate(Thread* thread, ThreadEntry entry, void* context) { - Thread id = sceKernelCreateThread("SceThread", _sceThreadEntry, 0x10000100, 0x10000, 0, 0, 0); + Thread id = sceKernelCreateThread("SceThread", _sceThreadEntry, 0x40, 0x10000, 0, 0x70000, 0); if (id < 0) { return id; }