diff options
| author | 2019-11-23 13:24:39 -0500 | |
|---|---|---|
| committer | 2019-11-23 13:24:39 -0500 | |
| commit | 6a3fc5d2ff2732e0392db56b04ff0c4e2c167bf2 (patch) | |
| tree | 7d8189083964982abf5e48e3dd8e87e504ca7ab6 /src/core/hle/kernel/process.cpp | |
| parent | Merge pull request #3141 from ReinUsesLisp/gl-position (diff) | |
| parent | Kernel: Optimize condition variable threads management. (diff) | |
| download | yuzu-6a3fc5d2ff2732e0392db56b04ff0c4e2c167bf2.tar.gz yuzu-6a3fc5d2ff2732e0392db56b04ff0c4e2c167bf2.tar.xz yuzu-6a3fc5d2ff2732e0392db56b04ff0c4e2c167bf2.zip | |
Merge pull request #3114 from FernandoS27/cond-var
Kernel: Correct behavior of Condition Variables to be more similar to real hardware.
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 12a900bcc..a4e0dd385 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -142,6 +142,48 @@ u64 Process::GetTotalPhysicalMemoryUsedWithoutSystemResource() const { | |||
| 142 | return GetTotalPhysicalMemoryUsed() - GetSystemResourceUsage(); | 142 | return GetTotalPhysicalMemoryUsed() - GetSystemResourceUsage(); |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | void Process::InsertConditionVariableThread(SharedPtr<Thread> thread) { | ||
| 146 | VAddr cond_var_addr = thread->GetCondVarWaitAddress(); | ||
| 147 | std::list<SharedPtr<Thread>>& thread_list = cond_var_threads[cond_var_addr]; | ||
| 148 | auto it = thread_list.begin(); | ||
| 149 | while (it != thread_list.end()) { | ||
| 150 | const SharedPtr<Thread> current_thread = *it; | ||
| 151 | if (current_thread->GetPriority() > thread->GetPriority()) { | ||
| 152 | thread_list.insert(it, thread); | ||
| 153 | return; | ||
| 154 | } | ||
| 155 | ++it; | ||
| 156 | } | ||
| 157 | thread_list.push_back(thread); | ||
| 158 | } | ||
| 159 | |||
| 160 | void Process::RemoveConditionVariableThread(SharedPtr<Thread> thread) { | ||
| 161 | VAddr cond_var_addr = thread->GetCondVarWaitAddress(); | ||
| 162 | std::list<SharedPtr<Thread>>& thread_list = cond_var_threads[cond_var_addr]; | ||
| 163 | auto it = thread_list.begin(); | ||
| 164 | while (it != thread_list.end()) { | ||
| 165 | const SharedPtr<Thread> current_thread = *it; | ||
| 166 | if (current_thread.get() == thread.get()) { | ||
| 167 | thread_list.erase(it); | ||
| 168 | return; | ||
| 169 | } | ||
| 170 | ++it; | ||
| 171 | } | ||
| 172 | UNREACHABLE(); | ||
| 173 | } | ||
| 174 | |||
| 175 | std::vector<SharedPtr<Thread>> Process::GetConditionVariableThreads(const VAddr cond_var_addr) { | ||
| 176 | std::vector<SharedPtr<Thread>> result{}; | ||
| 177 | std::list<SharedPtr<Thread>>& thread_list = cond_var_threads[cond_var_addr]; | ||
| 178 | auto it = thread_list.begin(); | ||
| 179 | while (it != thread_list.end()) { | ||
| 180 | SharedPtr<Thread> current_thread = *it; | ||
| 181 | result.push_back(current_thread); | ||
| 182 | ++it; | ||
| 183 | } | ||
| 184 | return result; | ||
| 185 | } | ||
| 186 | |||
| 145 | void Process::RegisterThread(const Thread* thread) { | 187 | void Process::RegisterThread(const Thread* thread) { |
| 146 | thread_list.push_back(thread); | 188 | thread_list.push_back(thread); |
| 147 | } | 189 | } |