From 29208a7fae7a32623b8e0348f00cc403a595d7d0 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 5 Jan 2014 00:28:59 -0800 Subject: [PATCH] Fixing broken spinlock. --- src/xenia/kernel/xboxkrnl_rtl.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/xenia/kernel/xboxkrnl_rtl.cc b/src/xenia/kernel/xboxkrnl_rtl.cc index 88646ce45..a558d1f22 100644 --- a/src/xenia/kernel/xboxkrnl_rtl.cc +++ b/src/xenia/kernel/xboxkrnl_rtl.cc @@ -751,12 +751,13 @@ void xeRtlEnterCriticalSection(uint32_t cs_ptr, uint32_t thread_id) { uint32_t spin_wait_remaining = cs->spin_count_div_256 * 256; spin: - if (xe_atomic_inc_32(&cs->lock_count)) { + if (xe_atomic_inc_32(&cs->lock_count) != 0) { // If this thread already owns the CS increment the recursion count. if (cs->owning_thread_id == thread_id) { cs->recursion_count++; return; } + xe_atomic_dec_32(&cs->lock_count); // Thread was locked - spin wait. if (spin_wait_remaining) {