summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorGravatar Subv2018-04-20 12:01:14 -0500
committerGravatar Subv2018-04-20 21:04:25 -0500
commite81a2080ebf9712231dd29c081141780ffd46cfb (patch)
treeb93d23dde3c3a0e86edeb44a1c1f1e18ac839bd6 /src/core/hle/kernel/thread.cpp
parentMerge pull request #367 from lioncash/clamp (diff)
downloadyuzu-e81a2080ebf9712231dd29c081141780ffd46cfb.tar.gz
yuzu-e81a2080ebf9712231dd29c081141780ffd46cfb.tar.xz
yuzu-e81a2080ebf9712231dd29c081141780ffd46cfb.zip
Kernel: Corrected the implementation of svcArbitrateLock and svcArbitrateUnlock.
Switch mutexes are no longer kernel objects, they are managed in userland and only use the kernel to handle the contention case. Mutex addresses store a special flag value (0x40000000) to notify the guest code that there are still some threads waiting for the mutex to be released. This flag is updated when a thread calls ArbitrateUnlock. TODO: * Fix svcWaitProcessWideKey * Fix svcSignalProcessWideKey * Remove the Mutex class.
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index f3a8aa4aa..0a0ad7cfb 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -126,6 +126,14 @@ static void ThreadWakeupCallback(u64 thread_handle, int cycles_late) {
126 resume = thread->wakeup_callback(ThreadWakeupReason::Timeout, thread, nullptr, 0); 126 resume = thread->wakeup_callback(ThreadWakeupReason::Timeout, thread, nullptr, 0);
127 } 127 }
128 128
129 if (thread->mutex_wait_address != 0 || thread->condvar_wait_address != 0 ||
130 thread->wait_handle) {
131 ASSERT(thread->status == THREADSTATUS_WAIT_MUTEX);
132 thread->mutex_wait_address = 0;
133 thread->condvar_wait_address = 0;
134 thread->wait_handle = 0;
135 }
136
129 if (resume) 137 if (resume)
130 thread->ResumeFromWait(); 138 thread->ResumeFromWait();
131} 139}
@@ -151,6 +159,7 @@ void Thread::ResumeFromWait() {
151 case THREADSTATUS_WAIT_HLE_EVENT: 159 case THREADSTATUS_WAIT_HLE_EVENT:
152 case THREADSTATUS_WAIT_SLEEP: 160 case THREADSTATUS_WAIT_SLEEP:
153 case THREADSTATUS_WAIT_IPC: 161 case THREADSTATUS_WAIT_IPC:
162 case THREADSTATUS_WAIT_MUTEX:
154 break; 163 break;
155 164
156 case THREADSTATUS_READY: 165 case THREADSTATUS_READY:
@@ -256,7 +265,9 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
256 thread->last_running_ticks = CoreTiming::GetTicks(); 265 thread->last_running_ticks = CoreTiming::GetTicks();
257 thread->processor_id = processor_id; 266 thread->processor_id = processor_id;
258 thread->wait_objects.clear(); 267 thread->wait_objects.clear();
259 thread->wait_address = 0; 268 thread->mutex_wait_address = 0;
269 thread->condvar_wait_address = 0;
270 thread->wait_handle = 0;
260 thread->name = std::move(name); 271 thread->name = std::move(name);
261 thread->callback_handle = wakeup_callback_handle_table.Create(thread).Unwrap(); 272 thread->callback_handle = wakeup_callback_handle_table.Create(thread).Unwrap();
262 thread->owner_process = owner_process; 273 thread->owner_process = owner_process;