Skip to content
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

Fix lock api #198

Merged
merged 3 commits into from
Apr 25, 2024
Merged

Fix lock api #198

merged 3 commits into from
Apr 25, 2024

Conversation

fjtrujy
Copy link
Member

@fjtrujy fjtrujy commented Apr 20, 2024

To have thread-safe operations for all the newlib operations we have been required to do several PR:

This PR skips the usage of the dummy lock API, letting us implement the specific one in the pspsdk/libcglue

Cheers

@@ -1099,7 +1099,7 @@ int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpat
{
// TODO: Do better implementation following https://linux.die.net/man/2/renameat
// for now use the same as rename
return _rename(oldpath, newpath);
return rename(oldpath, newpath);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix dummy warning

@@ -589,6 +589,17 @@ int sceKernelPollSema(SceUID semaid, int signal);
*/
int sceKernelReferSemaStatus(SceUID semaid, SceKernelSemaInfo *info);

/** Attribute for lightweight mutex. */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding extra documentation for lightweight mutex

@diamant3
Copy link
Member

Thank you for the PRs @fjtrujy

@diamant3 diamant3 merged commit 54db1f0 into pspdev:master Apr 25, 2024
1 check passed
@rofl0r
Copy link
Contributor

rofl0r commented Apr 26, 2024

it's kinda odd that the PSP kernel even ships these functions since it's inherently non-parallel with its use of cooperative multitasking, except when using the Media Engine CPU - but from what i gathered from looking at the code of uofw, for those locks it uses custom code. maybe @fjtrujy can shed some light ?

@fjtrujy
Copy link
Member Author

fjtrujy commented Apr 26, 2024

it's kinda odd that the PSP kernel even ships these functions since it's inherently non-parallel with its use of cooperative multitasking, except when using the Media Engine CPU - but from what i gathered from looking at the code of uofw, for those locks it uses custom code. maybe @fjtrujy can shed some light ?

Not sure what specific stuff do you want to know more about?
Do you mean about recursive mutex?

@rofl0r
Copy link
Contributor

rofl0r commented Apr 26, 2024

no, i mean why does the PSP OS provide mutexes, locks and semaphores when there's no real parallel execution ?

@fjtrujy
Copy link
Member Author

fjtrujy commented Apr 26, 2024

no, i mean why does the PSP OS provide mutexes, locks, and semaphores when there's no real parallel execution?

If you have a fully single thread, obviously you can’t have concurrency issues, but as soon as you start “emulating threads” (have in mind that PSP hardware is still a single thread), you must have them otherwise you can suffer concurrency issues.
The swap between threads in PSP happens as soon as the current thread enters sleep mode (tons of ways to do this, the easiest is to run nanosleep function), or because interruptions with higher priorities are executed, jumping to a different part of your code… this is why, sometimes you see how interruptions are disabled, in this way, you can assure your execution is not going to stop and jump to a different place… (that was the very first implementation of thread safe allocation on newlib in PSP years ago…)
Not sure if I have replied to your question, but this is a generic question in terms of “concurrency issues“

@fjtrujy fjtrujy deleted the fix_LockAPI branch May 17, 2024 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants