Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Re: Thread priorities
  1999-03-12  5:00 Thread priorities Rob
@ 1999-03-12  5:00 ` Jeff Denham
  1999-03-16  5:00   ` Rob Kirkbride
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Denham @ 1999-03-12  5:00 UTC (permalink / raw)


Rob wrote:

> Can someone either point me to a reference or provide some clarification how
> the priority adjustment is performed in Digital Unix?
>
> My understanding is that if a thread becomes CPU intensive the scheduler can
> reduce its priority and similarly if a process is blocked waiting then the
> scheduler can increase its priority.
>
> I have written a kernel debugger extension to print out various fields from
> the thread structure and it seems that the inverse seems to be happening (at
> least with respect to the threads that are busy). In other words the number
> is reducing which for Mach priorities indicates that its priority is
> increasing.
>
> If anyone can shed any light on the calculation of these fields, or any of
> the fields in the thread structure it would be appreciated.
>
> Rob Kirkbride (rob@rk-comp.demon.co.uk)

Mach priorities in Tru64 go from 0 (highest) to 64 (lowest).
Posix priorities go the other way. Check out the -O SCHED
flag to the ps command for a peek at the views of your threads'
prios. Also check out the _Guide_to_Realtime_Programming_,
which has a chapter on scheduling.

It POSIX terms, if I recall correctly, the scheme looks like this:

0-19:       User range
20-31:     System range
32-63:     Realtime range

The base priority for a thread is 19 (BASEPRI_USER)  (44 in Mach
terms). This priority degrades from here down to 0, depending
on the number of compute cycles and the nice value for the thread.

In the thread structure, there's several sched fields (from faulty
memory):

th_priority:  the thread's "base" priority. Normally this is Mach 44
                    but can be higher if the thread is running in a nice-d
process

th_schedpri: the thread's effective (current priority). This determines
                     which of the 64 run queues a thread will pend in before
                     running and its "importance" when running. This is
                     one that gets jerked around by the scheduler's weighting
                     algorithms.

th_policy:   timeshare, fixed-pri round-robin, fixed-pri fifo...

Don't know if any of this helps. There's also a Digital Technical
Journal article online (from 1995 or so) that gives some more
details on the affects of SMP on scheduling and how kernel
preemption works.

Uresh Valhalia's _UNIX_Internals:_The_New_Frontiers_
(Pretice Hall) has some info on DEC OSF/1 scheduling
as well, but he mangled it pretty badly!

-- Jeff
__________________________________________________
Jeff Denham (jdenham@brighttiger.com)

Bright Tiger Technologies:  Resource-management software
for building and managing fast, reliable web sites
See us at http://www.brighttiger.com

125 Nagog Park
Acton, MA 01720
Phone: (978) 263-5455 x177
Fax:   (978) 263-5547





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Thread priorities
@ 1999-03-12  5:00 Rob
  1999-03-12  5:00 ` Jeff Denham
  0 siblings, 1 reply; 4+ messages in thread
From: Rob @ 1999-03-12  5:00 UTC (permalink / raw)


Can someone either point me to a reference or provide some clarification how
the priority adjustment is performed in Digital Unix?

My understanding is that if a thread becomes CPU intensive the scheduler can
reduce its priority and similarly if a process is blocked waiting then the
scheduler can increase its priority.

I have written a kernel debugger extension to print out various fields from
the thread structure and it seems that the inverse seems to be happening (at
least with respect to the threads that are busy). In other words the number
is reducing which for Mach priorities indicates that its priority is
increasing.

If anyone can shed any light on the calculation of these fields, or any of
the fields in the thread structure it would be appreciated.

Rob Kirkbride (rob@rk-comp.demon.co.uk)









^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Thread priorities
  1999-03-12  5:00 ` Jeff Denham
@ 1999-03-16  5:00   ` Rob Kirkbride
  1999-03-16  5:00     ` Jeff Denham
  0 siblings, 1 reply; 4+ messages in thread
From: Rob Kirkbride @ 1999-03-16  5:00 UTC (permalink / raw)


I've got a copy of the Guide to Realtime Scheduling, and I do understand the
distinction between POSIX priorities and MACH priorities.

I am more interested in the algorithm which the scheduler uses for adjusting
the priorities. I have used ps -o SCHED as well as the kernel debugger for
determining thread priorities but this does not reveal why a threads
priority may have been changed.

ps and the kernel debugger still seem to show busy threads have increased
their priority. I am wondering if maybe a thread could be blocked on a
device (which I think can result in its priority being increased) and then
goes busy. If the scheduler hasn't got around to reducing its priority back
again will it still have a raised priority?

Rob

Jeff Denham wrote in message <36E92C41.8A412DBD@brighttiger.com>...
>Rob wrote:
>
>> Can someone either point me to a reference or provide some clarification
how
>> the priority adjustment is performed in Digital Unix?
>>
>> My understanding is that if a thread becomes CPU intensive the scheduler
can
>> reduce its priority and similarly if a process is blocked waiting then
the
>> scheduler can increase its priority.
>>
>> I have written a kernel debugger extension to print out various fields
from
>> the thread structure and it seems that the inverse seems to be happening
(at
>> least with respect to the threads that are busy). In other words the
number
>> is reducing which for Mach priorities indicates that its priority is
>> increasing.
>>
>> If anyone can shed any light on the calculation of these fields, or any
of
>> the fields in the thread structure it would be appreciated.
>>
>> Rob Kirkbride (rob@rk-comp.demon.co.uk)
>
>Mach priorities in Tru64 go from 0 (highest) to 64 (lowest).
>Posix priorities go the other way. Check out the -O SCHED
>flag to the ps command for a peek at the views of your threads'
>prios. Also check out the _Guide_to_Realtime_Programming_,
>which has a chapter on scheduling.
>
>It POSIX terms, if I recall correctly, the scheme looks like this:
>
>0-19:       User range
>20-31:     System range
>32-63:     Realtime range
>
>The base priority for a thread is 19 (BASEPRI_USER)  (44 in Mach
>terms). This priority degrades from here down to 0, depending
>on the number of compute cycles and the nice value for the thread.
>
>In the thread structure, there's several sched fields (from faulty
>memory):
>
>th_priority:  the thread's "base" priority. Normally this is Mach 44
>                    but can be higher if the thread is running in a nice-d
>process
>
>th_schedpri: the thread's effective (current priority). This determines
>                     which of the 64 run queues a thread will pend in
before
>                     running and its "importance" when running. This is
>                     one that gets jerked around by the scheduler's
weighting
>                     algorithms.
>
>th_policy:   timeshare, fixed-pri round-robin, fixed-pri fifo...
>
>Don't know if any of this helps. There's also a Digital Technical
>Journal article online (from 1995 or so) that gives some more
>details on the affects of SMP on scheduling and how kernel
>preemption works.
>
>Uresh Valhalia's _UNIX_Internals:_The_New_Frontiers_
>(Pretice Hall) has some info on DEC OSF/1 scheduling
>as well, but he mangled it pretty badly!
>
>-- Jeff
>__________________________________________________






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Thread priorities
  1999-03-16  5:00   ` Rob Kirkbride
@ 1999-03-16  5:00     ` Jeff Denham
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Denham @ 1999-03-16  5:00 UTC (permalink / raw)


Rob Kirkbride wrote:

> I've got a copy of the Guide to Realtime Scheduling, and I do understand the
> distinction between POSIX priorities and MACH priorities.
>
> I am more interested in the algorithm which the scheduler uses for adjusting
> the priorities. I have used ps -o SCHED as well as the kernel debugger for
> determining thread priorities but this does not reveal why a threads
> priority may have been changed.
>
> ps and the kernel debugger still seem to show busy threads have increased
> their priority. I am wondering if maybe a thread could be blocked on a
> device (which I think can result in its priority being increased) and then
> goes busy. If the scheduler hasn't got around to reducing its priority back
> again will it still have a raised priority?

Ah. Well, the algorithms are mostly traditional BSD-style
weighted decay blah, blah, blah. There's some proprietary
twists thrown in to smooth out the scheduler's timeshare
behaviors. I don't think you'll be able to find out much more
without sources.

I think what might be seeing is the 2-level priority boost given
to threads blocking in the kernel. Whether this happens or
not is controlled by a kernel variable called, IIRC, give_boost.
I believe you can change it via sysconfigtab, but don't remember what
fields to add and no longer have access to a DU machine. Do
an nm or strings on vmunix and grep for boost for a start.

BTW, that Digital Tech Journal article is at

http://www.digital.com/DTJF03/DTJF03SC.TXT

FWIW...





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-03-16  5:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-03-12  5:00 Thread priorities Rob
1999-03-12  5:00 ` Jeff Denham
1999-03-16  5:00   ` Rob Kirkbride
1999-03-16  5:00     ` Jeff Denham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox