diff options
Diffstat (limited to 'src/core/hle/kernel/mutex.cpp')
| -rw-r--r-- | src/core/hle/kernel/mutex.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 8d92a9b8e..072e4e7c1 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp | |||
| @@ -40,31 +40,19 @@ SharedPtr<Mutex> Mutex::Create(bool initial_locked, std::string name) { | |||
| 40 | mutex->name = std::move(name); | 40 | mutex->name = std::move(name); |
| 41 | mutex->holding_thread = nullptr; | 41 | mutex->holding_thread = nullptr; |
| 42 | 42 | ||
| 43 | // Acquire mutex with current thread if initialized as locked... | 43 | // Acquire mutex with current thread if initialized as locked |
| 44 | if (initial_locked) | 44 | if (initial_locked) |
| 45 | mutex->Acquire(); | 45 | mutex->Acquire(GetCurrentThread()); |
| 46 | 46 | ||
| 47 | return mutex; | 47 | return mutex; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | bool Mutex::ShouldWait() { | 50 | bool Mutex::ShouldWait(Thread* thread) const { |
| 51 | auto thread = GetCurrentThread(); | 51 | return lock_count > 0 && thread != holding_thread; |
| 52 | bool wait = lock_count > 0 && holding_thread != thread; | ||
| 53 | |||
| 54 | // If the holding thread of the mutex is lower priority than this thread, that thread should | ||
| 55 | // temporarily inherit this thread's priority | ||
| 56 | if (wait && thread->current_priority < holding_thread->current_priority) | ||
| 57 | holding_thread->BoostPriority(thread->current_priority); | ||
| 58 | |||
| 59 | return wait; | ||
| 60 | } | ||
| 61 | |||
| 62 | void Mutex::Acquire() { | ||
| 63 | Acquire(GetCurrentThread()); | ||
| 64 | } | 52 | } |
| 65 | 53 | ||
| 66 | void Mutex::Acquire(SharedPtr<Thread> thread) { | 54 | void Mutex::Acquire(Thread* thread) { |
| 67 | ASSERT_MSG(!ShouldWait(), "object unavailable!"); | 55 | ASSERT_MSG(!ShouldWait(thread), "object unavailable!"); |
| 68 | 56 | ||
| 69 | // Actually "acquire" the mutex only if we don't already have it... | 57 | // Actually "acquire" the mutex only if we don't already have it... |
| 70 | if (lock_count == 0) { | 58 | if (lock_count == 0) { |