summaryrefslogtreecommitdiff
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
authorGravatar Subv2017-01-04 10:53:01 -0500
committerGravatar Subv2017-01-05 09:40:14 -0500
commitfd95b6ee2606da4cd47c5f2916ad3b4f86c0e0f4 (patch)
tree5a3d1487e24f089b68358ddd8984c12e65623055 /src/core/hle/svc.cpp
parentKernel: Use different thread statuses when a thread calls WaitSynchronization... (diff)
downloadyuzu-fd95b6ee2606da4cd47c5f2916ad3b4f86c0e0f4.tar.gz
yuzu-fd95b6ee2606da4cd47c5f2916ad3b4f86c0e0f4.tar.xz
yuzu-fd95b6ee2606da4cd47c5f2916ad3b4f86c0e0f4.zip
Kernel: Remove Thread::wait_objects_index and use wait_objects to hold all the objects that a thread is waiting on.
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r--src/core/hle/svc.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 1e1ca5180..855f3af82 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -277,6 +277,7 @@ static ResultCode WaitSynchronization1(Kernel::Handle handle, s64 nano_seconds)
277 if (nano_seconds == 0) 277 if (nano_seconds == 0)
278 return ERR_SYNC_TIMEOUT; 278 return ERR_SYNC_TIMEOUT;
279 279
280 thread->wait_objects = {object};
280 object->AddWaitingThread(thread); 281 object->AddWaitingThread(thread);
281 thread->status = THREADSTATUS_WAIT_SYNCH_ANY; 282 thread->status = THREADSTATUS_WAIT_SYNCH_ANY;
282 283
@@ -325,11 +326,6 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha
325 objects[i] = object; 326 objects[i] = object;
326 } 327 }
327 328
328 // Clear the mapping of wait object indices.
329 // We don't want any lingering state in this map.
330 // It will be repopulated later in the wait_all = false case.
331 thread->wait_objects_index.clear();
332
333 if (wait_all) { 329 if (wait_all) {
334 bool all_available = 330 bool all_available =
335 std::all_of(objects.begin(), objects.end(), 331 std::all_of(objects.begin(), objects.end(),
@@ -358,7 +354,6 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha
358 object->AddWaitingThread(thread); 354 object->AddWaitingThread(thread);
359 } 355 }
360 356
361 // Set the thread's waitlist to the list of objects passed to WaitSynchronizationN
362 thread->wait_objects = std::move(objects); 357 thread->wait_objects = std::move(objects);
363 358
364 // Create an event to wake the thread up after the specified nanosecond delay has passed 359 // Create an event to wake the thread up after the specified nanosecond delay has passed
@@ -395,17 +390,14 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha
395 // Put the thread to sleep 390 // Put the thread to sleep
396 thread->status = THREADSTATUS_WAIT_SYNCH_ANY; 391 thread->status = THREADSTATUS_WAIT_SYNCH_ANY;
397 392
398 // Clear the thread's waitlist, we won't use it for wait_all = false
399 thread->wait_objects.clear();
400
401 // Add the thread to each of the objects' waiting threads. 393 // Add the thread to each of the objects' waiting threads.
402 for (size_t i = 0; i < objects.size(); ++i) { 394 for (size_t i = 0; i < objects.size(); ++i) {
403 Kernel::WaitObject* object = objects[i].get(); 395 Kernel::WaitObject* object = objects[i].get();
404 // Set the index of this object in the mapping of Objects -> index for this thread.
405 thread->wait_objects_index[object->GetObjectId()] = static_cast<int>(i);
406 object->AddWaitingThread(thread); 396 object->AddWaitingThread(thread);
407 } 397 }
408 398
399 thread->wait_objects = std::move(objects);
400
409 // Note: If no handles and no timeout were given, then the thread will deadlock, this is 401 // Note: If no handles and no timeout were given, then the thread will deadlock, this is
410 // consistent with hardware behavior. 402 // consistent with hardware behavior.
411 403