summaryrefslogtreecommitdiff
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2015-04-09 23:05:49 -0400
committerGravatar bunnei2015-04-09 23:05:49 -0400
commit6f1143885bcc02642b707b51355fe4b6cd5375c7 (patch)
treefe1307919e7087df41c498b971016ffa931d6594 /src/core/hle/svc.cpp
parentMerge pull request #690 from Zaneo/sharedmemory (diff)
parentSVC: Assert on unsupported CreateThread processor ID. (diff)
downloadyuzu-6f1143885bcc02642b707b51355fe4b6cd5375c7.tar.gz
yuzu-6f1143885bcc02642b707b51355fe4b6cd5375c7.tar.xz
yuzu-6f1143885bcc02642b707b51355fe4b6cd5375c7.zip
Merge pull request #683 from bunnei/thread-priority
Thread priority and scheduler improvements
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r--src/core/hle/svc.cpp52
1 files changed, 45 insertions, 7 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index bbb4eb9cd..76e9b171a 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -283,8 +283,13 @@ static ResultCode ArbitrateAddress(Handle handle, u32 address, u32 type, u32 val
283 if (arbiter == nullptr) 283 if (arbiter == nullptr)
284 return ERR_INVALID_HANDLE; 284 return ERR_INVALID_HANDLE;
285 285
286 return arbiter->ArbitrateAddress(static_cast<Kernel::ArbitrationType>(type), 286 auto res = arbiter->ArbitrateAddress(static_cast<Kernel::ArbitrationType>(type),
287 address, value, nanoseconds); 287 address, value, nanoseconds);
288
289 if (res == RESULT_SUCCESS)
290 HLE::Reschedule(__func__);
291
292 return res;
288} 293}
289 294
290/// Used to output a message on a debug hardware unit - does nothing on a retail unit 295/// Used to output a message on a debug hardware unit - does nothing on a retail unit
@@ -312,7 +317,7 @@ static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_lim
312} 317}
313 318
314/// Creates a new thread 319/// Creates a new thread
315static ResultCode CreateThread(u32* out_handle, u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 processor_id) { 320static ResultCode CreateThread(Handle* out_handle, s32 priority, u32 entry_point, u32 arg, u32 stack_top, s32 processor_id) {
316 using Kernel::Thread; 321 using Kernel::Thread;
317 322
318 std::string name; 323 std::string name;
@@ -323,6 +328,27 @@ static ResultCode CreateThread(u32* out_handle, u32 priority, u32 entry_point, u
323 name = Common::StringFromFormat("unknown-%08x", entry_point); 328 name = Common::StringFromFormat("unknown-%08x", entry_point);
324 } 329 }
325 330
331 // TODO(bunnei): Implement resource limits to return an error code instead of the below assert.
332 // The error code should be: Description::NotAuthorized, Module::OS, Summary::WrongArgument,
333 // Level::Permanent
334 ASSERT_MSG(priority >= THREADPRIO_USERLAND_MAX, "Unexpected thread priority!");
335
336 if (priority > THREADPRIO_LOWEST) {
337 return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS,
338 ErrorSummary::InvalidArgument, ErrorLevel::Usage);
339 }
340
341 switch (processor_id) {
342 case THREADPROCESSORID_DEFAULT:
343 case THREADPROCESSORID_0:
344 case THREADPROCESSORID_1:
345 break;
346 default:
347 // TODO(bunnei): Implement support for other processor IDs
348 ASSERT_MSG(false, "Unsupported thread processor ID: %d", processor_id);
349 break;
350 }
351
326 CASCADE_RESULT(SharedPtr<Thread> thread, Kernel::Thread::Create( 352 CASCADE_RESULT(SharedPtr<Thread> thread, Kernel::Thread::Create(
327 name, entry_point, priority, arg, processor_id, stack_top)); 353 name, entry_point, priority, arg, processor_id, stack_top));
328 CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(thread))); 354 CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(thread)));
@@ -331,10 +357,7 @@ static ResultCode CreateThread(u32* out_handle, u32 priority, u32 entry_point, u
331 "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point, 357 "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point,
332 name.c_str(), arg, stack_top, priority, processor_id, *out_handle); 358 name.c_str(), arg, stack_top, priority, processor_id, *out_handle);
333 359
334 if (THREADPROCESSORID_1 == processor_id) { 360 HLE::Reschedule(__func__);
335 LOG_WARNING(Kernel_SVC,
336 "thread designated for system CPU core (UNIMPLEMENTED) will be run with app core scheduling");
337 }
338 361
339 return RESULT_SUCCESS; 362 return RESULT_SUCCESS;
340} 363}
@@ -374,8 +397,11 @@ static ResultCode CreateMutex(Handle* out_handle, u32 initial_locked) {
374 SharedPtr<Mutex> mutex = Mutex::Create(initial_locked != 0); 397 SharedPtr<Mutex> mutex = Mutex::Create(initial_locked != 0);
375 CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(mutex))); 398 CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(mutex)));
376 399
400 HLE::Reschedule(__func__);
401
377 LOG_TRACE(Kernel_SVC, "called initial_locked=%s : created handle=0x%08X", 402 LOG_TRACE(Kernel_SVC, "called initial_locked=%s : created handle=0x%08X",
378 initial_locked ? "true" : "false", *out_handle); 403 initial_locked ? "true" : "false", *out_handle);
404
379 return RESULT_SUCCESS; 405 return RESULT_SUCCESS;
380} 406}
381 407
@@ -390,6 +416,9 @@ static ResultCode ReleaseMutex(Handle handle) {
390 return ERR_INVALID_HANDLE; 416 return ERR_INVALID_HANDLE;
391 417
392 mutex->Release(); 418 mutex->Release();
419
420 HLE::Reschedule(__func__);
421
393 return RESULT_SUCCESS; 422 return RESULT_SUCCESS;
394} 423}
395 424
@@ -428,6 +457,9 @@ static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count)
428 return ERR_INVALID_HANDLE; 457 return ERR_INVALID_HANDLE;
429 458
430 CASCADE_RESULT(*count, semaphore->Release(release_count)); 459 CASCADE_RESULT(*count, semaphore->Release(release_count));
460
461 HLE::Reschedule(__func__);
462
431 return RESULT_SUCCESS; 463 return RESULT_SUCCESS;
432} 464}
433 465
@@ -520,6 +552,9 @@ static ResultCode SetTimer(Handle handle, s64 initial, s64 interval) {
520 return ERR_INVALID_HANDLE; 552 return ERR_INVALID_HANDLE;
521 553
522 timer->Set(initial, interval); 554 timer->Set(initial, interval);
555
556 HLE::Reschedule(__func__);
557
523 return RESULT_SUCCESS; 558 return RESULT_SUCCESS;
524} 559}
525 560
@@ -534,6 +569,9 @@ static ResultCode CancelTimer(Handle handle) {
534 return ERR_INVALID_HANDLE; 569 return ERR_INVALID_HANDLE;
535 570
536 timer->Cancel(); 571 timer->Cancel();
572
573 HLE::Reschedule(__func__);
574
537 return RESULT_SUCCESS; 575 return RESULT_SUCCESS;
538} 576}
539 577