kernel: Back to SCHED_OTHER

This commit is contained in:
IndecisiveTurtle 2024-06-16 00:17:57 +03:00
parent 54721d7565
commit 7577bd4e77
3 changed files with 9 additions and 50 deletions

View file

@ -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;

View file

@ -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<Map> 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();

View file

@ -25,7 +25,7 @@ struct wrapper_impl<name, PS4_SYSV_ABI R (*)(Args...), f> {
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<R, s32> || std::is_same_v<R, u32>) {
const u32 ret = f(args...);
@ -42,8 +42,8 @@ struct wrapper_impl<name, PS4_SYSV_ABI R (*)(Args...), f> {
template <StringLiteral name, class F, F f>
constexpr auto wrapper = wrapper_impl<name, F, f>::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) \
{ \