// 222: 9-10us void PspSpeedTests::changePrioritySpeed(int id, int priority) { uint32 time1 = PspRtc::instance().getMicros(); sceKernelChangeThreadPriority(id, priority); uint32 time2 = PspRtc::instance().getMicros(); PSP_INFO_PRINT("Changing thread priority to %d for id %d took %dus\n", priority, id, time2-time1); }
static void execPriorityTests(int attr, int changePriority) { printf("For attr %08X%s:\n", attr, changePriority ? " and changed priorities" : ""); schedulingLogPos = 0; SceUID threads[7]; int test[7] = {1, 2, 3, 4, 5, 6, 7}; mbx = sceKernelCreateMbx("mbx1", attr, NULL); PRINT_MBX(mbx); sendMbx(mbx, 0x20); sendMbx(mbx, 0x10); int i; for (i = 0; i < 7; i++) { threads[i] = CREATE_PRIORITY_THREAD(threadFunction, 0x18 - i); sceKernelStartThread(threads[i], sizeof(int), (void*)&test[i]); } sceKernelDelayThread(10 * 1000); // What we're gonna do now is change the threads' priorities to see whether // priority at time of wait (already happened) or at time of send matters. if (changePriority) { for (i = 0; i < 7; i++) { sceKernelChangeThreadPriority(threads[i], 0x18 - 7 + i); } printf("Priorities reversed. Have a nice day.\n"); } schedf("---\n"); PRINT_MBX(mbx); schedf("---\n"); sendMbx(mbx, 0x15); sceKernelDelayThread(10 * 1000); schedf("---\n"); PRINT_MBX(mbx); schedf("---\n"); sendMbx(mbx, 0x20); sendMbx(mbx, 0x10); sceKernelDelayThread(10 * 1000); schedf("---\n"); PRINT_MBX(mbx); schedf("---\n"); sceKernelDeleteMbx(mbx); schedf("\n\n"); printf("%s", schedulingLog); }
static void VITAAUD_ThreadInit(_THIS) { /* Increase the priority of this audio thread by 1 to put it ahead of other SDL threads. */ SceUID thid; SceKernelThreadInfo info; thid = sceKernelGetThreadId(); info.size = sizeof(SceKernelThreadInfo); if (sceKernelGetThreadInfo(thid, &info) == 0) { sceKernelChangeThreadPriority(thid, info.currentPriority - 1); } }
static void PSPAUDIO_ThreadInit(_THIS) { /* Increase the priority of this audio thread by 1 to put it ahead of other SDL threads. */ SceUID thid; SceKernelThreadInfo status; thid = sceKernelGetThreadId(); status.size = sizeof(SceKernelThreadInfo); if (sceKernelReferThreadStatus(thid, &status) == 0) { sceKernelChangeThreadPriority(thid, status.currentPriority - 1); } }
int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { int value; if (priority == SDL_THREAD_PRIORITY_LOW) { value = 19; } else if (priority == SDL_THREAD_PRIORITY_HIGH) { value = -20; } else { value = 0; } return sceKernelChangeThreadPriority(sceKernelGetThreadId(),value); }
static int music_thread(SceSize arg, void *argp) { u32 key = 0; u32 oldkey = 0; u64 start, end; double interval = 0; g_thread_actived = 1; g_thread_exited = 0; sceRtcGetCurrentTick(&start); sceRtcGetCurrentTick(&end); while (g_thread_actived) { music_lock(); if (g_list.is_list_playing) { if (musicdrv_has_stop()) { if (g_list.first_time) { int ret; ret = music_play(g_list.curr_pos); if (ret == 0) g_list.first_time = false; } else { get_next_music(); if (!g_list.is_list_playing) { music_unlock(); music_load(g_list.curr_pos); music_stop(); continue; } music_play(g_list.curr_pos); } } music_unlock(); sceKernelDelayThread(100000); } else { music_unlock(); sceKernelDelayThread(500000); } if (g_music_hprm_enable) { key = ctrl_hprm_raw(); sceRtcGetCurrentTick(&end); interval = pspDiffTime(&end, &start); if (key == PSP_HPRM_FORWARD || key == PSP_HPRM_BACK || key == PSP_HPRM_PLAYPAUSE) { if (key != oldkey) { sceRtcGetCurrentTick(&start); sceRtcGetCurrentTick(&end); interval = pspDiffTime(&end, &start); } if (interval >= 0.5) { if (key == PSP_HPRM_FORWARD) { musicdrv_fforward(5); sceKernelDelayThread(200000); } else if (key == PSP_HPRM_BACK) { musicdrv_fbackward(5); sceKernelDelayThread(200000); } } oldkey = key; if (key == PSP_HPRM_PLAYPAUSE && interval >= 4.0) { power_down(); scePowerRequestSuspend(); } } else { if ((oldkey == PSP_HPRM_FORWARD || oldkey == PSP_HPRM_BACK || oldkey == PSP_HPRM_PLAYPAUSE)) { if (interval < 0.5) { if (oldkey == PSP_HPRM_FORWARD) music_next(); else if (oldkey == PSP_HPRM_BACK) music_prev(); } if (interval < 4.0) { if (oldkey == PSP_HPRM_PLAYPAUSE) music_list_playorpause(); } } oldkey = key; sceRtcGetCurrentTick(&start); } } { int thid = sceKernelGetThreadId(); int oldpri = sceKernelGetThreadCurrentPriority(); sceKernelChangeThreadPriority(thid, 90); cache_routine(); sceKernelChangeThreadPriority(thid, oldpri); } } g_thread_actived = 0; g_thread_exited = 1; return 0; }