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 

Creating another thread.

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



Joined: 18 Mar 2010
Posts: 5

PostPosted: Thu Mar 18, 2010 10:26 am    Post subject: Creating another thread. Reply with quote

This time something more usefull.

I have my basic engine made with GL,
all i am missing now is a thread with networking code inside.
As i'll be using custom made TCP implementation to handle the network,
all i really need is a separate thread running :

Code:
//pseudocode
while(1){
getpacket
analyzepacket
}
//endofpseudocode



How to spawn/create a separate thread ?

many thanks for any help!
_________________
perfection is the key.
Back to top
View user's profile Send private message Visit poster's website
codemaster



Joined: 18 Mar 2010
Posts: 5

PostPosted: Thu Mar 18, 2010 10:50 am    Post subject: Reply with quote

Got it.

Many thanks anyways :)

Code:
NETWORK_threadid = sceKernelCreateThread("NETWORK_thread", NETWORK_thread, 0x18, 0x10000, PSP_THREAD_ATTR_USER, NULL);

_________________
perfection is the key.
Back to top
View user's profile Send private message Visit poster's website
NoEffex



Joined: 27 Nov 2008
Posts: 108

PostPosted: Fri Mar 19, 2010 9:12 am    Post subject: Reply with quote

codemaster wrote:
Got it.

Many thanks anyways :)

Code:
NETWORK_threadid = sceKernelCreateThread("NETWORK_thread", NETWORK_thread, 0x18, 0x10000, PSP_THREAD_ATTR_USER, NULL);


+

Code:
sceKernelStartThread(NETWORK_threadid, 0, NULL);

_________________
Programming with:
Geany + Latest PSPSDK from svn
Back to top
View user's profile Send private message
roby65



Joined: 01 Jun 2008
Posts: 55
Location: Mid Italy

PostPosted: Fri Mar 19, 2010 10:49 pm    Post subject: Reply with quote

Are you tring to use blocking socket?
In this case your method won't work:
if the networking thread blocks on recv, then the other thread can't run.
Simply use non-blocking socket as i'm doing :)
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
codemaster



Joined: 18 Mar 2010
Posts: 5

PostPosted: Sun Mar 21, 2010 1:34 am    Post subject: Reply with quote

roby65 wrote:
Are you tring to use blocking socket?
In this case your method won't work:
if the networking thread blocks on recv, then the other thread can't run.
Simply use non-blocking socket as i'm doing :)


Socket in nonblocking mode in a code :

Code:

//PSEUDOCODE
NETWORKTHREAD(){
while(1){

l=recvfrom(...)

switch(packet.data){

}
Sleep_microseconds(1);
}

}


Shouldn't block the main thread in PSP right?

Thx roby.
_________________
perfection is the key.
Back to top
View user's profile Send private message Visit poster's website
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