Repository navigation
feat(libkernel): add mutex ownership, relative lock and spin/yield accessors - #8400
Conversation
Progress report (f894ba6 → 31fc06b)📈 System libraries: 50.64% (+0.06%, +10 implemented functions) ✅ 10 implemented
|
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
- [pthread_mutex_reltimedlock_np](../../../core/libs/prx/libkernel/Pthread/Posix/Mutex.cpp) (libkernel) takes `(mutex, usec)`, a relative timeout in microseconds, and is `scePthreadMutexTimedlock` with POSIX error numbers. FreeBSD 11.4 has no such function; the signature comes only from shadPS4, which registers one function for this NID and for `scePthreadMutexTimedlock` ([`mutex.cpp`](https://github.com/shadps4-emu/shadPS4/blob/3a9f57265d28975658f1ca941daa5c879c7a74bd/src/core/libraries/kernel/threads/mutex.cpp#L284-L287)). shadPS4 reads a 64-bit count; here it is the 32-bit `SceKernelUseconds` of the SCE twin, as for `pthread_cond_reltimedwait_np`. Unverified on the console |
|
@slider The code looks right to me: the spin defaults reach every creation path (the no-attr One thing before it can go in, the same point nikowolf123 made: After that, the bar is a full CI run with |
…cessors Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QnkpF2oEMofseVz9Z7WEAC
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QnkpF2oEMofseVz9Z7WEAC
6127294 to
31fc06b
Compare
|
Thanks @nikowolf123 and @oneandonlydean. Added the debt entry next to Also rebased onto current main; |
|
Checked the FreeBSD 11.4 |
What
Adds 10 missing libkernel mutex extensions, following FreeBSD 11.4 libthr (
thr_mutex.c):pthread_mutex_isowned_np: 1 when the calling thread owns the mutex, otherwise 0. A static initializer or destroyed mutex reports 0 without being initialized, as_pthread_mutex_isowned_npdoes.pthread_mutex_reltimedlock_np: the POSIX name of the existing relativescePthreadMutexTimedlock, with the same static-initializer handling as the other POSIX lock calls.pthread_mutex_getspinloops_np,pthread_mutex_setspinloops_np,pthread_mutex_getyieldloops_npandpthread_mutex_setyieldloops_np, plusscePthreadMutexGetspinloops,Setspinloops,GetyieldloopsandSetyieldloops. They followcheck_and_init_mutex: a static initializer is initialized and a destroyed mutex returnsEINVAL. The exception is setting the yield count, which returns 0 as FreeBSD's__pthread_mutex_setyieldloops_npdoes.mutex_init_bodydefaults: 2000 spins for an adaptive mutex and 0 otherwise.PthreadMutexPrivate::SetTypesets them at the three places a mutex is created.docs/dev/debt/libkernel.md): the counts are stored and reported but host mutexes do not spin or yield by them, and the console's defaults are unverified.Left out on purpose:
pthread_mutex_getprioceilingandsetprioceiling(and their SCE names): mutexes here do not carry the priority protocol, and FreeBSD's setter locks the mutex throughUMTX_OP_SET_CEILING.scePthreadMutexIsowned: shadPS4 wraps it with the error-convertingORBIS()wrapper, which would turn "owned" into0x80020001. Its console behaviour is undocumented.No overlap with #8373: the branches merge cleanly (
git merge-tree).Tested
Linux (Ubuntu 24.04, GCC 13.3, Release):
guest_pthread_mutex_errorspass: ownership from the owner and another thread,reltimedlock_npdeadlock and timeout, destroyed and static-initializer mutexes, and spin/yield defaults per type, round trips and errors.guest_pthread_mutexattr,guest_cond_timedwait,guest_cond_recursive_mutex,guest_pthread_destroyed_objectsandguest_kernel_errorspass.tools/check_conventions.py --base origin/mainpasses.Windows: the changed sources and test pass a syntax-only check with MinGW-w64 GCC 13 (not the supported 15.2); not built or run.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)