Operating System - HP-UX
1834631 Members
3132 Online
110069 Solutions
New Discussion

Questions about HP-UX 11i process and thread priorities

 
Jimmie Mayfield
Occasional Contributor

Questions about HP-UX 11i process and thread priorities

Hi. I read the relevant sections from the book "HP-UX 11i Internals" and I still have some questions:

I understand how to calculate the user-level priority using the formula:

new priority = (puser + kt_cpu/4) - 2 * (pnice - p_nice)

Scenario: Program 'foo' running at niceness of 20 has 3 threads. Thread #0 is in an infinite usleep() loop. Threads #1 and #2 are simply spinning in a loop while printing a counter to stdout.

Using pstat_getlwps() I have the following snapshot:

thread #0: lwp_pri = 168, lwp_cpu = 0
thread #1: lwp_pri = 241, lwp_cpu = 255
thread #2: lwp_pri = 241, lwp_cpu = 255

all 3 threads have lwp_schedpolicy = 1 (PS_TIMESHARE)

Plugging 'lwp_cpu' in for 'kt_cpu' in the above formula, I can calculate the following:

thread #0 priority: 178
thread #1 priority: 241
thread #2 priority: 241

So, for threads #1 and #2, my calculated priorities match those in 'lwp_pri'. But it doesn't match for thread #0 even though the scheduler is the same.

Also, using pstat_getproc() to query the whole process, I find the following:
pst_pri = 152
pst_schedpolicy = 1 (PS_TIMESHARE)

I'm not sure how to interpret the priority of 152. That seems awfully strong (according to the book, this falls into the range of system priorities that delay incoming signals). In fact, a quick glance at ps -l output shows most processes with a priority of 154 or below.

My question: assuming the above formula is correct, what is the relation between the priorities computed by the formula and the 'lwp_pri' and 'pst_pri' priorities returned by the pstat functions? There seem to be some discrepencies.

1 REPLY 1
Florian Heigl (new acc)
Honored Contributor

Re: Questions about HP-UX 11i process and thread priorities

that part in the book only made my head feel strange :)

I could only guess that the looping without real processing happing somehow gets the threads a too high priority.
i'm getting that feeling again.
yesterday I stood at the edge. Today I'm one step ahead.