From 7577bd4e77cf438f28a6693b34b41cbec4c784ad Mon Sep 17 00:00:00 2001 From: IndecisiveTurtle <47210458+raphaelthegreat@users.noreply.github.com> Date: Sun, 16 Jun 2024 00:17:57 +0300 Subject: [PATCH] kernel: Back to SCHED_OTHER --- .../libraries/kernel/thread_management.cpp | 22 ++++--------- src/core/libraries/kernel/thread_management.h | 31 ------------------- src/core/libraries/libs.h | 6 ++-- 3 files changed, 9 insertions(+), 50 deletions(-) diff --git a/src/core/libraries/kernel/thread_management.cpp b/src/core/libraries/kernel/thread_management.cpp index 804e18c56..dbc775480 100644 --- a/src/core/libraries/kernel/thread_management.cpp +++ b/src/core/libraries/kernel/thread_management.cpp @@ -42,7 +42,6 @@ void init_pthreads() { scePthreadRwlockattrInit(&default_rwattr); g_pthread_cxt->setDefaultRwattr(default_rwattr); - g_pthread_cxt->setPthreadKeys(new PthreadKeys); g_pthread_cxt->SetPthreadPool(new PThreadPool); } @@ -237,8 +236,9 @@ int PS4_SYSV_ABI scePthreadAttrSetschedparam(ScePthreadAttr* attr, pparam.sched_priority = 0; } - int result = pthread_attr_setschedparam(&(*attr)->pth_attr, &pparam); - + // We always use SCHED_OTHER for now, so don't call this for now. + //int result = pthread_attr_setschedparam(&(*attr)->pth_attr, &pparam); + int result = 0; return result == 0 ? SCE_OK : SCE_KERNEL_ERROR_EINVAL; } @@ -271,19 +271,9 @@ int PS4_SYSV_ABI scePthreadAttrSetschedpolicy(ScePthreadAttr* attr, int policy) return SCE_KERNEL_ERROR_EINVAL; } - int ppolicy = SCHED_OTHER; - switch (policy) { - case 0: - ppolicy = SCHED_OTHER; - break; - case 1: - ppolicy = SCHED_FIFO; - break; - case 3: - ppolicy = SCHED_OTHER; - break; - default: - UNREACHABLE(); + int ppolicy = SCHED_OTHER; // winpthreads only supports SCHED_OTHER + if (policy != SCHED_OTHER) { + LOG_ERROR(Kernel_Pthread, "policy={} not supported by winpthreads", policy); } (*attr)->policy = policy; diff --git a/src/core/libraries/kernel/thread_management.h b/src/core/libraries/kernel/thread_management.h index 1909ffd3a..fddf4cddb 100644 --- a/src/core/libraries/kernel/thread_management.h +++ b/src/core/libraries/kernel/thread_management.h @@ -111,30 +111,6 @@ private: std::mutex m_mutex; }; -class PthreadKeys { -public: - PthreadKeys() {} - virtual ~PthreadKeys() {} - - bool CreateKey(int* key, PthreadKeyDestructor destructor); - bool GetKey(int key, int thread_id, void** data); - bool SetKey(int key, int thread_id, void* data); - -private: - struct Map { - int thread_id = -1; - void* data = nullptr; - }; - - struct Key { - bool used = false; - PthreadKeyDestructor destructor = nullptr; - std::vector specific_values; - }; - - std::mutex m_mutex; - Key m_keys[256]; -}; class PThreadCxt { public: ScePthreadMutexattr* getDefaultMutexattr() { @@ -167,12 +143,6 @@ public: void setDefaultRwattr(OrbisPthreadRwlockattr attr) { m_default_Rwattr = attr; } - PthreadKeys* getPthreadKeys() { - return m_pthread_keys; - } - void setPthreadKeys(PthreadKeys* keys) { - m_pthread_keys = keys; - } private: ScePthreadMutexattr m_default_mutexattr = nullptr; @@ -180,7 +150,6 @@ private: ScePthreadAttr m_default_attr = nullptr; PThreadPool* m_pthread_pool = nullptr; OrbisPthreadRwlockattr m_default_Rwattr = nullptr; - PthreadKeys* m_pthread_keys = nullptr; }; void init_pthreads(); diff --git a/src/core/libraries/libs.h b/src/core/libraries/libs.h index 72eca312c..601d01cf4 100644 --- a/src/core/libraries/libs.h +++ b/src/core/libraries/libs.h @@ -25,7 +25,7 @@ struct wrapper_impl { static R PS4_SYSV_ABI wrap(Args... args) { if (std::string_view(name.value) != "scePthreadEqual" && std::string_view(name.value) != "sceUserServiceGetEvent") { - LOG_WARNING(Core_Linker, "Function {} called", name.value); + //LOG_WARNING(Core_Linker, "Function {} called", name.value); } if constexpr (std::is_same_v || std::is_same_v) { const u32 ret = f(args...); @@ -42,8 +42,8 @@ struct wrapper_impl { template constexpr auto wrapper = wrapper_impl::wrap; -// #define W(foo) wrapper<#foo, decltype(&foo), foo> -#define W(foo) foo +#define W(foo) wrapper<#foo, decltype(&foo), foo> +//#define W(foo) foo #define LIB_FUNCTION(nid, lib, libversion, mod, moduleVersionMajor, moduleVersionMinor, function) \ { \