Threading

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

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
cwbowron
Posts: 76
Joined: Fri May 06, 2005 4:22 am
Location: East Lansing, MI
Contact:

Threading

Post by cwbowron »

I'm working on pondering for pspChess which requires multiple threads. There's a post from TyRaNiD in this thread: http://forums.ps2dev.org/viewtopic.php?t=1594&start=0 which says:
sceKernelCreateThread(const char *name, void *func, int initpriority, int stacksize, int extra1, int extra2). Extra 1 and 2 seem to almost always be zero it seems. Also bear in mind like the ps2 the psp seems to have co-operative threading which means you either need to call sceKernelRotateThreadReadyQueue to switch to the next thread or sleep etc. And priorities are lowest is highest ;)
In my testing it appears that some calls such as sceDisplayWaitVblankStart and/or sceCtrlReadBufferPositive will give up the timeslice and switch to a different thread.

I've got everything mostly working, but I was wondering if anyone has more information on what is really going on? When I actually try to use the sceKernelThreadSleep functions and such I cannot get it to work, but by the use of sceDisplayWaitVblankStart and/or sceCtrlReadBufferPositive seems to switch threads correctly.

Thanks.
Post Reply