-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mutex and LwMutex not correctly implemented #18
Comments
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:
TBH, I don't really know what lwmutexes are though, I assume it means "lightweight"? What I do know:
-[Unknown] |
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). |
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] |
So, I think I implemented timeouts correctly using CoreTiming::ScheduleEvent in 1c20718e3cf2d94620703a9a44bd6db772767f76. I've also added better scheduling testing which is showing more issues.
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] |
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.. |
BTW, nice work on the timeout implementation! Doing it that way looks right. |
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 |
No description provided.
The text was updated successfully, but these errors were encountered: