diff options
| author | 2015-04-03 18:40:16 -0400 | |
|---|---|---|
| committer | 2015-04-09 19:06:39 -0400 | |
| commit | 9c3419ebccf046e0a123e0516ea134547393e451 (patch) | |
| tree | 24073b71ade88e5f99db439b824228bdc6b2737d /src/core/hle/kernel/mutex.cpp | |
| parent | Thread: Implement priority boost for starved threads. (diff) | |
| download | yuzu-9c3419ebccf046e0a123e0516ea134547393e451.tar.gz yuzu-9c3419ebccf046e0a123e0516ea134547393e451.tar.xz yuzu-9c3419ebccf046e0a123e0516ea134547393e451.zip | |
Kernel: Implemented priority inheritance for mutexes.
Diffstat (limited to 'src/core/hle/kernel/mutex.cpp')
| -rw-r--r-- | src/core/hle/kernel/mutex.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index be2c49706..ebc9e79d7 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp | |||
| @@ -56,7 +56,15 @@ SharedPtr<Mutex> Mutex::Create(bool initial_locked, std::string name) { | |||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | bool Mutex::ShouldWait() { | 58 | bool Mutex::ShouldWait() { |
| 59 | return lock_count > 0 && holding_thread != GetCurrentThread();; | 59 | auto thread = GetCurrentThread(); |
| 60 | bool wait = lock_count > 0 && holding_thread != thread; | ||
| 61 | |||
| 62 | // If the holding thread of the mutex is lower priority than this thread, that thread should | ||
| 63 | // temporarily inherit this thread's priority | ||
| 64 | if (wait && thread->current_priority < holding_thread->current_priority) | ||
| 65 | holding_thread->BoostPriority(thread->current_priority); | ||
| 66 | |||
| 67 | return wait; | ||
| 60 | } | 68 | } |
| 61 | 69 | ||
| 62 | void Mutex::Acquire() { | 70 | void Mutex::Acquire() { |