| View previous topic :: View next topic |
| Author |
Message |
tkondal
Joined: 25 May 2006 Posts: 8
|
Posted: Sat Nov 11, 2006 4:06 pm Post subject: Calling a function periodically |
|
|
Hi,
I need a function to be called every x milliseconds. I have used the following functions on Windows : SetTimer() and KillTimer().
I looked into the PSPSDK documentation and the only two functions that I found (that I think could do the job) are the following: sceKernelSetAlarm() and sceKernelCancelAlarm().
However, I am not sure how to use these. The documentation does not provide too much information on these. I want to know if these are the appropriate functions to do a periodic call.
I was wondering if anyone has already used these and could point me in the right direction on what parameters to pass (small example).
Thanks. |
|
| Back to top |
|
 |
adrahil
Joined: 16 Mar 2006 Posts: 277
|
Posted: Sat Nov 11, 2006 8:07 pm Post subject: |
|
|
uhm..... why not do a thread with low priority which has something like:
| Code: | while(!quit){
sceKernelDelayThread(milliseconds);
my_function();
} |
|
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Sat Nov 11, 2006 8:23 pm Post subject: |
|
|
I dont know what part of the documentation you say is lacking but in my eyes it makes perfect sense.
i.e. do
| Code: | SceUInt alarm_handler(void *common)
{
// Do something, wont run in a thread so will have to set a semaphore or event flag
}
void set_alarm(void)
{
SceUID uid;
// Set an alarm for 1 second in the future
uid = sceKernelSetAlarm(1000000, alarm_handler, NULL);
}
|
|
|
| Back to top |
|
 |
|