-
Notifications
You must be signed in to change notification settings - Fork 74
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
About adding a pthread library #45
Comments
Actually, digging a bit around, I found that @kakaroto already worked on does anyone knows if this psl1ght library works, or if it was only a PoC? In any case, I'll try to build it and see how it goes. |
pretty sure it was complete and worked, but it's been so long, and don't think it was heavily tested either. |
thanks @kakaroto for the information! 😄 I'll share my feedback if I can run some tests with the Edit: I confirm that the library compiles Ok with the latest PSL1GHT from master branch. The only change needed was to replace |
well, I tried running a basic test app with the pthread library but it didn't work, it freezes on the About the build, I get some warnings but I'm not sure if it can be related:
This is the basic test sample I tried: #include <pthread.h>
#include <stdio.h>
/* this function is run by the second thread */
void *inc_x(void *x_void_ptr)
{
/* increment x to 100 */
int *x_ptr = (int *)x_void_ptr;
while(++(*x_ptr) < 100);
printf("x increment finished\n");
/* the function must return something - NULL will do */
return NULL;
}
int main()
{
int x = 0, y = 0;
/* show the initial values of x and y */
printf("x: %d, y: %d\n", x, y);
/* this variable is our reference to the second thread */
pthread_t inc_x_thread;
printf("creating thread...\n");
/* create a second thread which executes inc_x(&x) */
if(pthread_create(&inc_x_thread, NULL, inc_x, &x)) {
printf("Error creating thread\n");
return 1;
}
printf("continue...\n");
/* increment y to 100 in the first thread */
while(++y < 100);
printf("y increment finished\n");
/* wait for the second thread to finish */
if(pthread_join(inc_x_thread, NULL)) {
printf("Error joining thread\n");
return 2;
}
/* show the results - x is now 100 thanks to the second thread */
printf("x: %d, y: %d\n", x, y);
return 0;
} |
I've created a branch based off of kakaroto's that should be compatible with the current psl1ght sdk. I've also removed the usage of sysDbgGetPPUThreadName as that requires debug flag to be enabled (DEX kernel). Instead it uses threadInfo struct which is a solution used in the ps2 pthread implementation which should work for most cases. Please note the commit for fixing the atomic macros will need to be pulled first before compiling against psl1ght as those have been added to the branch as well. |
hi @OsirizX , this is awesome! I'll try to build your branch and give it a try when I have a chance 👍 so cool to see you around the ps3 again 😃 |
@OsirizX , I tested your updated pthread library and my basic test app worked just fine 💪
btw, I sent a small PR to your fork, with some minor adjustments to On a related topic, should we create PRs to @kakaroto original repo, or you prefer to use your fork for now? |
We can stick to my fork for now. I may make more changes to it and create a PR at a later time |
ok, sounds good. 👍 If I have a chance I'll add a simple |
Merged the sysAtomicSwap fix, seems someone's typo tool changed that at some point in time (maybe mine? Lol) |
Ok nvm, @shagkur just missed them in a refactor, can't believe we haven't seen that since 2011 😂 |
pthread-emb added here #64 |
While trying to update/build some libraries like cURL, I saw that we don't have a pthread library and we need to rely on a
--disable-thread
option (if available).Looking around, I saw that in the PSP/Vita homebrew sdk they built a pthread library, based on pthread-win32:
https://github.com/vitasdk/pthread-embedded
Could be possible to port this library to the PS3? from what I could check on the source code, they're building wrappers around the Mutex, Semaphores, and Threads from the SCE sdk, to offer a pthread interface.
In Psl1ght we do have access to the mutex, sems and threads too, so I think this would be a possibility, right?
If anyone with proper knowledge of pthread, threads, mutex, and semaphores could look into it, I'll be happy to help. 😄
My knowledge is limited in this topic (I haven't done any mutex/sem/thread stuff since college), and I don't want to just replace code lines blind, but I feel it could be a nice addition.
From my quick check on
/platform/psp/psp_osal.c
, we would need to change with proper PS3 calls:The text was updated successfully, but these errors were encountered: