PlayStation 4 emulator for Windows, Linux, macOS and FreeBSD written in C++
Kernel.Pthread: Various fixes (#4406)
* Fix for SignalTo behavior Should run FindThread to make sure thread input is valid. * Missing mutex-related exports * Oops * All missing cond exports We have these implemented, so we might as well export them. I also organized them a bit. * Implement pthread_attr_getscope, pthread_attr_setcreatesuspend_np, pthread_attr_setscope Also export all of our pthread_attr functions. * Oops * Fix SchedPolicy::Fifo definition Some tricks FreeBSD source performs breaks with this incorrectly set. Specifically, stuff like setting priorities breaks because we do array accesses with priority - 1 like FreeBSD, but Fifo being 0 makes that an oob read. * Fix error checks in pthread_attr_setschedparam * Fix and run thread destructors _sceKernelSetThreadDtors receives the function itself, not a pointer to the function. * Oops * Rewrite pthread_rename_np for accuracy There's a couple details the initial implementation missed that decomp shows. We weren't locking, we weren't doing the reference add or delete ops, and we were erroneously skipping null names when real hardware actually seems to allow it (the only thing real hardware skips for null name is naming the thread stack). * Avoid changing common code by using the converted thread name instead Slightly cleaner code * Oops * Flip priority defines This better matches with FreeBSD's defines, and fixes the returns of sched_get_priority_min and sched_get_priority_max * Fix args and return for sched_get_priority_max and sched_get_priority_min Behavior is based on my own kernel decomp (though what I'm seeing matches what red_prig's done for fpPS4 too). * Better comment why not * Fix error behavior of scePthreadGetPrio Can error from invalid thread input, which the function hardcodes as an ORBIS_KERNEL_ERROR_ESRCH. * Fix pthread_setprio This should use the RefAdd and RefDelete functions on non-curthread threads, not FindThread. * Remove pthread_set_name_np Decomp shows it's identical to pthread_rename_np. * Bring back pthread_set_name_np What I didn't realize was that it was a void method. Behavior is the same as pthread_rename_np though, so call it instead of doing the direct common setname call. * Move pthread_set_name_np Needs to be under pthread_rename_np so I can actually call it. * Better implementation of pthread_getname_np * rwlock types Some Sony extension to rwlocks, paired with a proper SDK check specific to rwlock init. I've implemented both pthread_rwlockattr_gettype_np and pthread_rwlockattr_settype_np, and added the relevant SDK check for rwlockattr type. * Missing thread unlock in SignalTo SignalTo specifically runs FindThread, then unlocks before running pretty much the same code as Signal. * Fix comment
S
Stephen Miller committed
65986d8a8acea4a65ea45d81ece87151ef0fa10f
Parent: 0add6b8
Committed by GitHub <noreply@github.com>
on 5/14/2026, 3:50:37 AM