summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Narr the Reg2022-12-15 13:22:07 -0600
committerGravatar Narr the Reg2022-12-15 13:44:21 -0600
commitdca4f0687a82b75382df9bf04a3f76c4afab56e2 (patch)
tree63cd36538d78b715a027dfb2ebb676735d130a4d
parentMerge pull request #9433 from Tachi107/cmake-is-awful (diff)
downloadyuzu-dca4f0687a82b75382df9bf04a3f76c4afab56e2.tar.gz
yuzu-dca4f0687a82b75382df9bf04a3f76c4afab56e2.tar.xz
yuzu-dca4f0687a82b75382df9bf04a3f76c4afab56e2.zip
kernel: process: Implement GetFreeThreadCount
Used by Just DanceĀ® 2023 Edition
-rw-r--r--src/core/hle/kernel/k_process.cpp11
-rw-r--r--src/core/hle/kernel/k_process.h3
-rw-r--r--src/core/hle/kernel/svc.cpp15
3 files changed, 28 insertions, 1 deletions
diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp
index d1dc62401..a1abf5d68 100644
--- a/src/core/hle/kernel/k_process.cpp
+++ b/src/core/hle/kernel/k_process.cpp
@@ -285,6 +285,17 @@ void KProcess::UnregisterThread(KThread* thread) {
285 thread_list.remove(thread); 285 thread_list.remove(thread);
286} 286}
287 287
288u64 KProcess::GetFreeThreadCount() const {
289 if (resource_limit != nullptr) {
290 const auto current_value =
291 resource_limit->GetCurrentValue(LimitableResource::ThreadCountMax);
292 const auto limit_value = resource_limit->GetLimitValue(LimitableResource::ThreadCountMax);
293 return limit_value - current_value;
294 } else {
295 return 0;
296 }
297}
298
288Result KProcess::Reset() { 299Result KProcess::Reset() {
289 // Lock the process and the scheduler. 300 // Lock the process and the scheduler.
290 KScopedLightLock lk(state_lock); 301 KScopedLightLock lk(state_lock);
diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h
index 2e0cc3d0b..09bf2f1d0 100644
--- a/src/core/hle/kernel/k_process.h
+++ b/src/core/hle/kernel/k_process.h
@@ -304,6 +304,9 @@ public:
304 /// from this process' thread list. 304 /// from this process' thread list.
305 void UnregisterThread(KThread* thread); 305 void UnregisterThread(KThread* thread);
306 306
307 /// Retrieves the number of available threads for this process.
308 u64 GetFreeThreadCount() const;
309
307 /// Clears the signaled state of the process if and only if it's signaled. 310 /// Clears the signaled state of the process if and only if it's signaled.
308 /// 311 ///
309 /// @pre The process must not be already terminated. If this is called on a 312 /// @pre The process must not be already terminated. If this is called on a
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index e520cab47..9fd7aae81 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -815,8 +815,15 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
815 // 6.0.0+ 815 // 6.0.0+
816 TotalPhysicalMemoryAvailableWithoutSystemResource = 21, 816 TotalPhysicalMemoryAvailableWithoutSystemResource = 21,
817 TotalPhysicalMemoryUsedWithoutSystemResource = 22, 817 TotalPhysicalMemoryUsedWithoutSystemResource = 22,
818 // 10.0.0+
819 IsApplication = 23,
820 // 13.0.0+
821 FreeThreadCount = 24,
822 // 14.0.0+
823 IsSvcPermitted = 26,
818 824
819 // Homebrew only 825 // Homebrew only
826 MesosphereMeta = 65000,
820 MesosphereCurrentProcess = 65001, 827 MesosphereCurrentProcess = 65001,
821 }; 828 };
822 829
@@ -840,7 +847,9 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
840 case GetInfoType::TitleId: 847 case GetInfoType::TitleId:
841 case GetInfoType::UserExceptionContextAddr: 848 case GetInfoType::UserExceptionContextAddr:
842 case GetInfoType::TotalPhysicalMemoryAvailableWithoutSystemResource: 849 case GetInfoType::TotalPhysicalMemoryAvailableWithoutSystemResource:
843 case GetInfoType::TotalPhysicalMemoryUsedWithoutSystemResource: { 850 case GetInfoType::TotalPhysicalMemoryUsedWithoutSystemResource:
851 case GetInfoType::IsApplication:
852 case GetInfoType::FreeThreadCount: {
844 if (info_sub_id != 0) { 853 if (info_sub_id != 0) {
845 LOG_ERROR(Kernel_SVC, "Info sub id is non zero! info_id={}, info_sub_id={}", info_id, 854 LOG_ERROR(Kernel_SVC, "Info sub id is non zero! info_id={}, info_sub_id={}", info_id,
846 info_sub_id); 855 info_sub_id);
@@ -929,6 +938,10 @@ static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle han
929 *result = process->GetTotalPhysicalMemoryUsedWithoutSystemResource(); 938 *result = process->GetTotalPhysicalMemoryUsedWithoutSystemResource();
930 return ResultSuccess; 939 return ResultSuccess;
931 940
941 case GetInfoType::FreeThreadCount:
942 *result = process->GetFreeThreadCount();
943 return ResultSuccess;
944
932 default: 945 default:
933 break; 946 break;
934 } 947 }