summaryrefslogtreecommitdiff
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
authorGravatar Subv2017-01-01 16:59:30 -0500
committerGravatar Subv2017-01-04 15:58:46 -0500
commit7abf1853907fe086753df0031262b668a2da88b0 (patch)
tree033c38e1d98f209c32c1378419468212729877b4 /src/core/hle/svc.cpp
parentKernel: Object ShouldWait and Acquire calls now take a thread as a parameter. (diff)
downloadyuzu-7abf1853907fe086753df0031262b668a2da88b0.tar.gz
yuzu-7abf1853907fe086753df0031262b668a2da88b0.tar.xz
yuzu-7abf1853907fe086753df0031262b668a2da88b0.zip
Kernel/Mutex: Implemented priority inheritance.
The implementation is based on reverse engineering of the 3DS's kernel. A mutex holder's priority will be temporarily boosted to the best priority among any threads that want to acquire any of its held mutexes. When the holder releases the mutex, it's priority will be boosted to the best priority among the threads that want to acquire any of its remaining held mutexes.
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r--src/core/hle/svc.cpp9
1 files changed, 0 insertions, 9 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 159ac0bf6..5d6359344 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -278,9 +278,6 @@ static ResultCode WaitSynchronization1(Kernel::Handle handle, s64 nano_seconds)
278 return ERR_SYNC_TIMEOUT; 278 return ERR_SYNC_TIMEOUT;
279 279
280 object->AddWaitingThread(thread); 280 object->AddWaitingThread(thread);
281 // TODO(Subv): Perform things like update the mutex lock owner's priority to
282 // prevent priority inversion. Currently this is done in Mutex::ShouldWait,
283 // but it should be moved to a function that is called from here.
284 thread->status = THREADSTATUS_WAIT_SYNCH; 281 thread->status = THREADSTATUS_WAIT_SYNCH;
285 282
286 // Create an event to wake the thread up after the specified nanosecond delay has passed 283 // Create an event to wake the thread up after the specified nanosecond delay has passed
@@ -359,9 +356,6 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha
359 // Add the thread to each of the objects' waiting threads. 356 // Add the thread to each of the objects' waiting threads.
360 for (auto& object : objects) { 357 for (auto& object : objects) {
361 object->AddWaitingThread(thread); 358 object->AddWaitingThread(thread);
362 // TODO(Subv): Perform things like update the mutex lock owner's priority to
363 // prevent priority inversion. Currently this is done in Mutex::ShouldWait,
364 // but it should be moved to a function that is called from here.
365 } 359 }
366 360
367 // Set the thread's waitlist to the list of objects passed to WaitSynchronizationN 361 // Set the thread's waitlist to the list of objects passed to WaitSynchronizationN
@@ -409,9 +403,6 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha
409 // Set the index of this object in the mapping of Objects -> index for this thread. 403 // Set the index of this object in the mapping of Objects -> index for this thread.
410 thread->wait_objects_index[object->GetObjectId()] = static_cast<int>(i); 404 thread->wait_objects_index[object->GetObjectId()] = static_cast<int>(i);
411 object->AddWaitingThread(thread); 405 object->AddWaitingThread(thread);
412 // TODO(Subv): Perform things like update the mutex lock owner's priority to
413 // prevent priority inversion. Currently this is done in Mutex::ShouldWait,
414 // but it should be moved to a function that is called from here.
415 } 406 }
416 407
417 // Note: If no handles and no timeout were given, then the thread will deadlock, this is 408 // Note: If no handles and no timeout were given, then the thread will deadlock, this is