question about sceKernelCreateThread

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

Moderators: cheriff, TyRaNiD

Post Reply
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

question about sceKernelCreateThread

Post by sauron_le_noir »

when creating a new thread with sceKernelCreateThread there is a initial stack
that you can give.as param
doest the newly created thread use this stack for malloc or does it use the global heap space
of the homebrew determine by the PSP_HEAP_SIZE_KB(-256);


Is there a IPC (inter process communication) mecanism that i can use if my first
thread ask my second thread to perform some work.

Is there a way for a thread to wait for a resource like a value of a variable

Is there a equivalent of a enter critical section all the process bloqued for example
on a list and just one process performing the update

The idea behind is a cache server for my pdf reader
he is started async with the main code and when i display the first page
i cache in asyn mode the page -1 and the page +1 so when the user want to go
to page 2 it is already loader and the rendering is immediate but to do this
i must protect the bitmap pointer with a critical section.
And the main thread must wait the cache server if the page is not already loaded
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

i saw in the sdk this
semaid = sceKernelCreateSema("MyMutex", 0, 1, 1, 0);

*
* @param name - Specifies the name of the sema
* @param attr - Sema attribute flags (normally set to 0)
* @param initVal - Sema initial value
* @param maxVal - Sema maximum value
* @param option - Sema options (normally set to 0)
* @return A semaphore id

int sceKernelWaitSema(SceUID semaid, int signal, SceUInt *timeout);
what value for timeout must a give to wait only for the release of the semaphore

is saw also in the sdk this

mbxid = sceKernelCreateMbx("MyMessagebox", 0, NULL);
* @endcode
*
* @param name - Specifies the name of the mbx
* @param attr - Mbx attribute flags (normally set to 0)
* @param option - Mbx options (normally set to NULL)
* @return A messagebox id


Has someone a example using semaphore,messagebox on the psp
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

repons to my question int the sdk folder in the samples there are samples
of messagebox ec ..
But the question about the heap and a thread and his private stack remains
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Well as with most systems the thread's stack is its own, where as the heap is shared between all threads. Mallocing will pull out of the total pool available.
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

thx as read in previous discussions the multi tasking iof psp s cooperatif and not preemptif
are all the api involve by this ?
if i pool for a system event or a message box does my main thread have cpu
i'm currently written a cache server for my pdf reader the idea behind is
start 2 threads. One handle the load and the cachin of pdf pages in fact in do
a rendering a create a raw ARGB buffer for the main code
So when the main code ask for page +1 or Page -1 the user has not to wait
when the page is not in cache i put the main thread in wait until the rendering is
done in the cache server
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Yah threading is co-operative, this seems to surprise people cause it has been rammed down their throats how pre-emptive is the shiz, well tbh that is only true when you have other stuff on the device you have no control over, not really applicable to the PSP.

As for ensuring things thread correctly well probably I would put the caching thread at a higher priority as that will mostly be waiting for IO anyway, however if all you are doing is wanting to prefetch stuff then you can use async IO and do it in one thread.
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

yes and no i must load the structure of the pdf a bunch of pointers but it is done once
the idea of 2 thread is i load the page asked and when this page is ready the main thread display it and ican navigate into the bitmap created. The cache server continue to prefetch page -1 and page +1 int the hope that the user will read the previous or next page.
The user ask page+1 it is directly available to rendering and the cache server preload -1 and +1 again etc....so even when the user read the current page in
background i preload page-1 and page+1
Post Reply