diff options
| author | 2016-12-04 09:58:36 -0500 | |
|---|---|---|
| committer | 2016-12-04 09:58:36 -0500 | |
| commit | bdad00c73f46106ba78995bdde1b50349e940b09 (patch) | |
| tree | 1c39ab11c8e995f2cbba8a5f602ab64819085b22 /src/core/hle/svc.cpp | |
| parent | Threading: Reworked the way our scheduler works. (diff) | |
| download | yuzu-bdad00c73f46106ba78995bdde1b50349e940b09.tar.gz yuzu-bdad00c73f46106ba78995bdde1b50349e940b09.tar.xz yuzu-bdad00c73f46106ba78995bdde1b50349e940b09.zip | |
Threading: Added some utility functions and const correctness.
Diffstat (limited to 'src/core/hle/svc.cpp')
| -rw-r--r-- | src/core/hle/svc.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 061692af8..c06df84b3 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -257,18 +257,21 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) { | |||
| 257 | 257 | ||
| 258 | if (object->ShouldWait()) { | 258 | if (object->ShouldWait()) { |
| 259 | 259 | ||
| 260 | if (nano_seconds == 0) | 260 | if (nano_seconds == 0) { |
| 261 | return ResultCode(ErrorDescription::Timeout, ErrorModule::OS, | 261 | return ResultCode(ErrorDescription::Timeout, ErrorModule::OS, |
| 262 | ErrorSummary::StatusChanged, | 262 | ErrorSummary::StatusChanged, |
| 263 | ErrorLevel::Info); | 263 | ErrorLevel::Info); |
| 264 | } | ||
| 264 | 265 | ||
| 265 | object->AddWaitingThread(thread); | 266 | object->AddWaitingThread(thread); |
| 267 | // TODO(Subv): Perform things like update the mutex lock owner's priority to prevent priority inversion. | ||
| 268 | // Currently this is done in Mutex::ShouldWait, but it should be moved to a function that is called from here. | ||
| 266 | thread->status = THREADSTATUS_WAIT_SYNCH; | 269 | thread->status = THREADSTATUS_WAIT_SYNCH; |
| 267 | 270 | ||
| 268 | // Create an event to wake the thread up after the specified nanosecond delay has passed | 271 | // Create an event to wake the thread up after the specified nanosecond delay has passed |
| 269 | thread->WakeAfterDelay(nano_seconds); | 272 | thread->WakeAfterDelay(nano_seconds); |
| 270 | 273 | ||
| 271 | // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to a signal in one of its wait objects. | 274 | // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to a signal in its wait objects. |
| 272 | // Otherwise we retain the default value of timeout. | 275 | // Otherwise we retain the default value of timeout. |
| 273 | return ResultCode(ErrorDescription::Timeout, ErrorModule::OS, | 276 | return ResultCode(ErrorDescription::Timeout, ErrorModule::OS, |
| 274 | ErrorSummary::StatusChanged, | 277 | ErrorSummary::StatusChanged, |
| @@ -312,7 +315,9 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou | |||
| 312 | objects[i] = object; | 315 | objects[i] = object; |
| 313 | } | 316 | } |
| 314 | 317 | ||
| 315 | // Clear the mapping of wait object indices | 318 | // Clear the mapping of wait object indices. |
| 319 | // We don't want any lingering state in this map. | ||
| 320 | // It will be repopulated later in the wait_all = false case. | ||
| 316 | thread->wait_objects_index.clear(); | 321 | thread->wait_objects_index.clear(); |
| 317 | 322 | ||
| 318 | if (!wait_all) { | 323 | if (!wait_all) { |
| @@ -345,12 +350,13 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou | |||
| 345 | thread->wait_objects.clear(); | 350 | thread->wait_objects.clear(); |
| 346 | 351 | ||
| 347 | // Add the thread to each of the objects' waiting threads. | 352 | // Add the thread to each of the objects' waiting threads. |
| 348 | for (int i = 0; i < objects.size(); ++i) { | 353 | for (size_t i = 0; i < objects.size(); ++i) { |
| 349 | ObjectPtr object = objects[i]; | 354 | ObjectPtr object = objects[i]; |
| 350 | // Set the index of this object in the mapping of Objects -> index for this thread. | 355 | // Set the index of this object in the mapping of Objects -> index for this thread. |
| 351 | thread->wait_objects_index[object->GetObjectId()] = i; | 356 | thread->wait_objects_index[object->GetObjectId()] = static_cast<int>(i); |
| 352 | object->AddWaitingThread(thread); | 357 | object->AddWaitingThread(thread); |
| 353 | // TODO(Subv): Perform things like update the mutex lock owner's priority to prevent priority inversion. | 358 | // TODO(Subv): Perform things like update the mutex lock owner's priority to prevent priority inversion. |
| 359 | // Currently this is done in Mutex::ShouldWait, but it should be moved to a function that is called from here. | ||
| 354 | } | 360 | } |
| 355 | 361 | ||
| 356 | // Note: If no handles and no timeout were given, then the thread will deadlock, this is consistent with hardware behavior. | 362 | // Note: If no handles and no timeout were given, then the thread will deadlock, this is consistent with hardware behavior. |
| @@ -396,6 +402,7 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou | |||
| 396 | for (auto object : objects) { | 402 | for (auto object : objects) { |
| 397 | object->AddWaitingThread(thread); | 403 | object->AddWaitingThread(thread); |
| 398 | // TODO(Subv): Perform things like update the mutex lock owner's priority to prevent priority inversion. | 404 | // TODO(Subv): Perform things like update the mutex lock owner's priority to prevent priority inversion. |
| 405 | // Currently this is done in Mutex::ShouldWait, but it should be moved to a function that is called from here. | ||
| 399 | } | 406 | } |
| 400 | 407 | ||
| 401 | // Create an event to wake the thread up after the specified nanosecond delay has passed | 408 | // Create an event to wake the thread up after the specified nanosecond delay has passed |
| @@ -1172,6 +1179,7 @@ void CallSVC(u32 immediate) { | |||
| 1172 | if (info) { | 1179 | if (info) { |
| 1173 | if (info->func) { | 1180 | if (info->func) { |
| 1174 | info->func(); | 1181 | info->func(); |
| 1182 | // TODO(Subv): Not all service functions should cause a reschedule in all cases. | ||
| 1175 | HLE::Reschedule(__func__); | 1183 | HLE::Reschedule(__func__); |
| 1176 | } else { | 1184 | } else { |
| 1177 | LOG_ERROR(Kernel_SVC, "unimplemented SVC function %s(..)", info->name); | 1185 | LOG_ERROR(Kernel_SVC, "unimplemented SVC function %s(..)", info->name); |