sceKernelCreateThread: optimal priority values

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

Moderators: cheriff, TyRaNiD

Post Reply
jockyw2001
Posts: 339
Joined: Thu Sep 29, 2005 4:19 pm

sceKernelCreateThread: optimal priority values

Post by jockyw2001 »

How can I determine the optimal priority value for a thread created with sceKernelCreateThread? For example in my app I have a network thread with priority 0x18, a decode thread with 0x16 and a video thread with 0x16. I noticed that the performance of my app can change rather dramatically if I tweak the priority values. So far it has been trial and error, I'm looking for a systematic approach.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Alas I do not think there is really much of a systematic approach you can take to thread priorities, it really depends on the types of work each thread is performing and how resistent they would be to interruptions. It also will depend how they interact with each other.

Based on your example I would probably say that the decode thread is probably doing the most work therefore it probably should have a lower thread priority (i.e. a higher number) than the other two as they are likely to be relatively short lived and reactive. In general I would say anything which tends to go into a wait state often (e.g. IO bound stuff such as a network thread or something limited by the blank interval such as a video thread) would need to be higher priority to ensure that they can react as quickly as possible to the event to prevent stalling the decode too much and go back as quickly as possible to the wait state.

Of course I dont know the exact work your code is doing, so it is hard to say for certain, it probably really is a case of suck it and see. I'll try to remember to add a function to tweak the thread priority from the psplink shell so you can test what works best at runtime :)
jockyw2001
Posts: 339
Joined: Thu Sep 29, 2005 4:19 pm

Post by jockyw2001 »

TyRaNiD wrote:I'll try to remember to add a function to tweak the thread priority from the psplink shell so you can test what works best at runtime :)
That would be wonderful. Psplink is already a HUGE timesaver and it's getting better all the time. Thank you very much.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Committed fyi.
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

o0oo very delicious commit :)
also note i find that you should never
go below 0x11 for priority as your update
thread should be at that level so no 0x01-0x11
should be touched
10011011 00101010 11010111 10001001 10111010
jonny
Posts: 351
Joined: Thu Sep 22, 2005 5:46 pm
Contact:

Post by jonny »

@dot_blank:

really interesting infos! (i guess there are some system threads that need to have more priority)
in pmpmod actually i have 3 threads with pri < 0x11 (4 if i count the implicit async-reading thread)
this can explain some rare problems i have while testing (i'm going to check)
KickinAezz
Posts: 328
Joined: Sun Jun 03, 2007 10:05 pm

Post by KickinAezz »

Tyranid wrote: I'll try to remember to add a function to tweak the thread priority from the psplink shell so you can test what works best at runtime :)
Which function is it?
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
Post Reply