| View previous topic :: View next topic |
| Author |
Message |
codemaster
Joined: 18 Mar 2010 Posts: 5
|
Posted: Thu Mar 18, 2010 10:26 am Post subject: Creating another thread. |
|
|
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 |
|
 |
codemaster
Joined: 18 Mar 2010 Posts: 5
|
Posted: Thu Mar 18, 2010 10:50 am Post subject: |
|
|
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 |
|
 |
NoEffex
Joined: 27 Nov 2008 Posts: 108
|
Posted: Fri Mar 19, 2010 9:12 am Post subject: |
|
|
| 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 |
|
 |
roby65
Joined: 01 Jun 2008 Posts: 55 Location: Mid Italy
|
Posted: Fri Mar 19, 2010 10:49 pm Post subject: |
|
|
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 |
|
 |
codemaster
Joined: 18 Mar 2010 Posts: 5
|
Posted: Sun Mar 21, 2010 1:34 am Post subject: |
|
|
| 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 |
|
 |
|