I don't understand why, when I use sceKernelSuspendThread (here in my function ~= xmbpause) I must wait a long time to see battery life time in the xmb.
But, when I don't use sceKernelSuspendThread, I can see rapidly battery life time in the xmb.
So I want to know how I can see rapidly battery life time when I use sceKernelSuspendThread :)
Here's a part of my code:
Code: Select all
void xmbpause(SceUID thid){
	if(pauseuid >= 0)
	return;
	pauseuid = thid;
	sceKernelGetThreadmanIdList(SCE_KERNEL_TMID_Thread, thread_buf_now, MAX_THREAD, &thread_count_now);
	int x, y, match;
	for(x = 0; x < thread_count_now; x++){
		match = 0;
		SceUID tmp_thid = thread_buf_now[x];
		for(y = 0; y < thread_count_start; y++){
			if((tmp_thid == thread_buf_start[y]) || (tmp_thid == thid)){
				match = 1;
				break;
			}
		}
		if(match == 0)
		sceKernelSuspendThread(tmp_thid);
	}
}
//resume game
void xmbresume(SceUID thid){
	if(pauseuid != thid)
	return;
	pauseuid = -1;
	int x, y, match;
	for(x = 0; x < thread_count_now; x++){
		match = 0;
		SceUID tmp_thid = thread_buf_now[x];
		for(y = 0; y < thread_count_start; y++){
			if((tmp_thid == thread_buf_start[y]) || (tmp_thid == thid)){
				match = 1;
				break;
			}
		}
		if(match == 0)
		sceKernelResumeThread(tmp_thid);
	}
}
int main_thread(SceSize args, void *argp)
{
	 unsigned int oldpad = 0;
	 
	 int info = 0;
	 char strinfo2[64];
	 
     SceCtrlData pad;
	 sceCtrlSetSamplingCycle(0);
	 sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
     
	 while(1) 
     {
         sceCtrlReadBufferPositive(&pad, 1);
		 
         if(info) {   
	     if(scePowerIsBatteryExist() > 0) {
         sprintf(strinfo2,"Hours Left (in min(~in h)) --> %d min approximately %d h", scePowerGetBatteryLifeTime(), scePowerGetBatteryLifeTime()/60);
         }
         else {
         sprintf(strinfo2,"Hours Left (in minutes(~in h)) --> ??");
         }	
		 }
         
		 if(pad.Buttons != oldpad) {
		     if(pad.Buttons & PSP_CTRL_SQUARE) {
		         if(info == 0) {
	                 info = 1;
				 }
 	             else if(info == 1) {
	                 info = 0;
	             }
             }
         } 
         oldpad = pad.Buttons;
		 
		 if(info) {
         blit_string(1,100,strinfo2,0x000000,0x111fff);	
		 xmbpause(main_thread);		 
		 }
		 else if(!info) {
		 xmbresume(main_thread);
		 }
		 
	   sceKernelDelayThread(100000);
     }
 return 0;
}
PS: I'm apologize for my bad English because I'm French :)
