forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What the fork()?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
TreGe



Joined: 14 May 2006
Posts: 2

PostPosted: Fri May 19, 2006 2:49 am    Post subject: What the fork()? Reply with quote

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?
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Fri May 19, 2006 3:16 am    Post subject: Reply with quote

By using the thread library like you are supposed to. sceKernelCreateThread/StartThread etc.
Back to top
View user's profile Send private message
TreGe



Joined: 14 May 2006
Posts: 2

PostPosted: Fri May 19, 2006 5:37 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Fri May 19, 2006 3:37 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group