mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-04-24 21:56:10 +03:00
[GH-ISSUE #18] Mutex and LwMutex not correctly implemented #8
Labels
No labels
Atrac3+
Audio
CPU emulation
D3D11
D3D9 (removed)
Depth / Z
Feature Request
Font Atlas
GE emulation
Guardband / Range Culling
HLE/Kernel
I/O
Input/Controller
MP3
Multithreading
Needs hardware testing
Networking/adhoc/infrastructure
No Feedback / Outdated?
OpenGL
PGF / sceFont
PSMF / MPEG
Platform-specific (Android)
Platform-specific (Windows)
Platform-specific (iOS)
PowerVR GPU
SDL2
Saving issue
User Interface
Vulkan
arm64jit
armjit
armv6
x86jit
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ppsspp#8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hrydgard on GitHub (Nov 6, 2012).
Original GitHub issue: https://github.com/hrydgard/ppsspp/issues/18
@unknownbrackets commented on GitHub (Nov 18, 2012):
So far I have mutexes mostly working and tested on my forks, but I've realized I'm not testing a few things which may matter...
Here's my todo list:
sceKernelTryLockLwMutex_600special.TBH, I don't really know what lwmutexes are though, I assume it means "lightweight"? What I do know:
NativeLwMutexwas changed in yaupspe and looks more correct there. (although not sure how to verify it.)-[Unknown]
@hrydgard commented on GitHub (Nov 18, 2012):
Nice!
About the workareas, I don't think games are very likely to be poking the workarea internals so it probably doesn't matter much exactly how the data inside is organized, as long as all the functions and synchronization behave correctly.
I also think "Lw" means lightweight, although they only appear to be marginally lighter than regular mutexes...
JPCSP has a mechanism where functions can have the attribute "banned in interrupts", we should probably implement that too (can just add an extra flags field to the hlemodule tables).
@unknownbrackets commented on GitHub (Nov 18, 2012):
Well, to me they seem less lightweight (require 32 bytes in userspace, still have a uid, at best maybe don't reschedule?) I'm worried access to the workarea (rather than a refer call) could be what makes them more "lightweight" (to use.)
But you're right, JPCSP doesn't preserve it and has reasonable compatibility so it can't matter too much.
-[Unknown]
@unknownbrackets commented on GitHub (Nov 19, 2012):
So, I think I implemented timeouts correctly using CoreTiming::ScheduleEvent in 1c20718e3cf2d94620703a9a44bd6db772767f76. I've also added better scheduling testing which is showing more issues.
sceKernelTryLockLwMutex_600seems to just give better error codes.Anyway, I noticed a big thing I'd totally forgotten about - threads ending. If a thread locks a mutex, and then ends, the mutex should be unlocked, of course. I can't wait for THREADEND, since I need finer control, and it needs to wakeup threads.
So I was thinking of adding a callback system to listen on threads ending, e.g. just a global std::vector of callbacks (which mutexes and semaphores would listen on, among maybe others?) that would get the thread id on return/exit/terminate. Does that sound right?
-[Unknown]
@hrydgard commented on GitHub (Nov 19, 2012):
Well, at least it doesn't really sound wrong, feel free to give it a shot :)
I wonder if games really do such silly things as locking a mutex and then exitthread, but I guess better safe than sorry..
@hrydgard commented on GitHub (Nov 19, 2012):
BTW, nice work on the timeout implementation! Doing it that way looks right.
@libcg commented on GitHub (Feb 25, 2013):
I'm currently reversing usersystemlib.prx. Here's a source file which could help you in this task :
https://github.com/uofw/uofw/blob/master/src/usersystemlib/kernel_library.c