summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2015-01-18 21:45:01 +0100
committerbunnei <bunneidev@gmail.com>2015-01-22 02:47:46 +0100
commitdde02f79af45fc01d747254eefbe680e580c3d45 (patch)
treebd91ce3b8e2db4280aaff1f00173911c32400d1d /src
parentKernel: Moved Wait and Acquire to WaitObject, added way to retrieve a WaitObject safely. (diff)
downloadyuzu-dde02f79af45fc01d747254eefbe680e580c3d45.tar
yuzu-dde02f79af45fc01d747254eefbe680e580c3d45.tar.gz
yuzu-dde02f79af45fc01d747254eefbe680e580c3d45.tar.bz2
yuzu-dde02f79af45fc01d747254eefbe680e580c3d45.tar.lz
yuzu-dde02f79af45fc01d747254eefbe680e580c3d45.tar.xz
yuzu-dde02f79af45fc01d747254eefbe680e580c3d45.tar.zst
yuzu-dde02f79af45fc01d747254eefbe680e580c3d45.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/mutex.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index 4a1eaca37..6cd140376 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -25,6 +25,7 @@ public:
bool locked; ///< Current locked state
Handle lock_thread; ///< Handle to thread that currently has mutex
std::string name; ///< Name of mutex (optional)
+ SharedPtr<Thread> current_thread; ///< Thread that has acquired the mutex
ResultVal<bool> Wait() override;
ResultVal<bool> Acquire() override;
@@ -43,6 +44,7 @@ static MutexMap g_mutex_held_locks;
void MutexAcquireLock(Mutex* mutex, Handle thread = GetCurrentThread()->GetHandle()) {
g_mutex_held_locks.insert(std::make_pair(thread, mutex->GetHandle()));
mutex->lock_thread = thread;
+ mutex->current_thread = Kernel::g_handle_table.Get<Thread>(thread);
}
/**
@@ -132,6 +134,7 @@ Mutex* CreateMutex(Handle& handle, bool initial_locked, const std::string& name)
mutex->locked = mutex->initial_locked = initial_locked;
mutex->name = name;
+ mutex->current_thread = nullptr;
// Acquire mutex with current thread if initialized as locked...
if (mutex->locked) {
@@ -157,7 +160,7 @@ Handle CreateMutex(bool initial_locked, const std::string& name) {
}
ResultVal<bool> Mutex::Wait() {
- return MakeResult<bool>(locked);
+ return MakeResult<bool>(locked && (current_thread != GetCurrentThread()));
}
ResultVal<bool> Mutex::Acquire() {