What the fork()?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
TreGe
Posts: 2
Joined: Sun May 14, 2006 6:58 am

What the fork()?

Post by TreGe »

I have made a couple of tiny apps for the PSP, and I'm currently working on something much bigger. Moving from a unix-ese background of c++ programming naturally the first think I thought to try with multithreading is the classic fork() instruction. While it did compile it did not create a child thread. So my question is: Has anyone tired multithreading a program and if so, how did you get it to work?
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

By using the thread library like you are supposed to. sceKernelCreateThread/StartThread etc.
TreGe
Posts: 2
Joined: Sun May 14, 2006 6:58 am

Post by TreGe »

Now can the stack frame fall through main or does it require to be de-instantiated using it's thread id? (aka, does the de-instantiation routine at the end of the main() function always kill the primary thread made upon instantiation of the program itself or the current thread being executed relative to the current stack frame)

Also, is the newly created stack frame empty or does it posess the information carried by the old thread (aka, can the new thread safely return from the function it started without underflowing the stack)

Since you were so nice about the last question, what about these?
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

When you return from a thread on the PSP the stack is maintained because the thread only goes in to an exited state instead of deleting itself. However you can call something like sceKernelExitDeleteThread() to ensure the thread exits and is removed from the system.

And as far as I know no infomation is implicitly carried over to the new thread, however when you start it you can pass an arbitrary binary string which will be copied onto the new threads stack.
Post Reply