From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,ad5311af1ae95293 X-Google-Attributes: gidfee84,public X-Google-Thread: 10650a,ad5311af1ae95293 X-Google-Attributes: gid10650a,public From: Jeff Denham Subject: Re: Thread priorities Date: 1999/03/12 Message-ID: <36E92C41.8A412DBD@brighttiger.com>#1/1 X-Deja-AN: 454214419 Content-Transfer-Encoding: 7bit References: <7caki3$fv8$1@news5.svr.pol.co.uk> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@digex.net X-Trace: dca1-nnrp1.news.digex.net 921250923 207.86.119.34 (Fri, 12 Mar 1999 10:02:03 EDT) Organization: Bright Tiger Technologies MIME-Version: 1.0 NNTP-Posting-Date: Fri, 12 Mar 1999 10:02:03 EDT Newsgroups: comp.unix.internals,comp.unix.osf.osf1 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