diff options
| author | 2019-11-21 11:03:37 -0400 | |
|---|---|---|
| committer | 2019-11-21 11:13:29 -0400 | |
| commit | 46bb6099814a6ff404d337164ced016ec04ea7b9 (patch) | |
| tree | 2ea68335bff35e36fa0999cef430ca022ecaae43 /src/core/hle/kernel/process.cpp | |
| parent | Kernel: Correct SignalProcessWideKey (diff) | |
| download | yuzu-46bb6099814a6ff404d337164ced016ec04ea7b9.tar.gz yuzu-46bb6099814a6ff404d337164ced016ec04ea7b9.tar.xz yuzu-46bb6099814a6ff404d337164ced016ec04ea7b9.zip | |
Kernel: Optimize condition variable threads management.
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 43576c6ab..a4e0dd385 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -143,31 +143,28 @@ u64 Process::GetTotalPhysicalMemoryUsedWithoutSystemResource() const { | |||
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | void Process::InsertConditionVariableThread(SharedPtr<Thread> thread) { | 145 | void Process::InsertConditionVariableThread(SharedPtr<Thread> thread) { |
| 146 | auto it = cond_var_threads.begin(); | 146 | VAddr cond_var_addr = thread->GetCondVarWaitAddress(); |
| 147 | while (it != cond_var_threads.end()) { | 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()) { | ||
| 148 | const SharedPtr<Thread> current_thread = *it; | 150 | const SharedPtr<Thread> current_thread = *it; |
| 149 | if (current_thread->GetCondVarWaitAddress() < thread->GetCondVarWaitAddress()) { | 151 | if (current_thread->GetPriority() > thread->GetPriority()) { |
| 150 | if (current_thread->GetCondVarWaitAddress() == thread->GetCondVarWaitAddress()) { | 152 | thread_list.insert(it, thread); |
| 151 | if (current_thread->GetPriority() > thread->GetPriority()) { | 153 | return; |
| 152 | cond_var_threads.insert(it, thread); | ||
| 153 | return; | ||
| 154 | } | ||
| 155 | } else { | ||
| 156 | cond_var_threads.insert(it, thread); | ||
| 157 | return; | ||
| 158 | } | ||
| 159 | } | 154 | } |
| 160 | ++it; | 155 | ++it; |
| 161 | } | 156 | } |
| 162 | cond_var_threads.push_back(thread); | 157 | thread_list.push_back(thread); |
| 163 | } | 158 | } |
| 164 | 159 | ||
| 165 | void Process::RemoveConditionVariableThread(SharedPtr<Thread> thread) { | 160 | void Process::RemoveConditionVariableThread(SharedPtr<Thread> thread) { |
| 166 | auto it = cond_var_threads.begin(); | 161 | VAddr cond_var_addr = thread->GetCondVarWaitAddress(); |
| 167 | while (it != cond_var_threads.end()) { | 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()) { | ||
| 168 | const SharedPtr<Thread> current_thread = *it; | 165 | const SharedPtr<Thread> current_thread = *it; |
| 169 | if (current_thread.get() == thread.get()) { | 166 | if (current_thread.get() == thread.get()) { |
| 170 | cond_var_threads.erase(it); | 167 | thread_list.erase(it); |
| 171 | return; | 168 | return; |
| 172 | } | 169 | } |
| 173 | ++it; | 170 | ++it; |
| @@ -177,12 +174,11 @@ void Process::RemoveConditionVariableThread(SharedPtr<Thread> thread) { | |||
| 177 | 174 | ||
| 178 | std::vector<SharedPtr<Thread>> Process::GetConditionVariableThreads(const VAddr cond_var_addr) { | 175 | std::vector<SharedPtr<Thread>> Process::GetConditionVariableThreads(const VAddr cond_var_addr) { |
| 179 | std::vector<SharedPtr<Thread>> result{}; | 176 | std::vector<SharedPtr<Thread>> result{}; |
| 180 | auto it = cond_var_threads.begin(); | 177 | std::list<SharedPtr<Thread>>& thread_list = cond_var_threads[cond_var_addr]; |
| 181 | while (it != cond_var_threads.end()) { | 178 | auto it = thread_list.begin(); |
| 179 | while (it != thread_list.end()) { | ||
| 182 | SharedPtr<Thread> current_thread = *it; | 180 | SharedPtr<Thread> current_thread = *it; |
| 183 | if (current_thread->GetCondVarWaitAddress() == cond_var_addr) { | 181 | result.push_back(current_thread); |
| 184 | result.push_back(current_thread); | ||
| 185 | } | ||
| 186 | ++it; | 182 | ++it; |
| 187 | } | 183 | } |
| 188 | return result; | 184 | return result; |