[3923] in java-interest

home help back first fref pref prev next nref lref last post

Re: Thread Scheduling in Win32

daemon@ATHENA.MIT.EDU (David Strauss)
Sun Dec 3 14:37:26 1995

Date: Sun, 3 Dec 1995 12:08:26 -0500 (EST)
To: java-interest@java.sun.com
From: dstrauss@panix.com (David Strauss)

In article <49hgm2$625@romeo.logica.co.uk>, stupplem@logica.com says...
>
>In article <49hf85$cmi@news1.panix.com>, dstrauss@panix.com says...
>>
>>There's an applet called RaceTest that accompanies the section on
>>thread priorities in the Java Progammer's Guide.  It creates two
>>"Runner" threads whose run method is a loop that counts up to
>>400K.  The runners do no I/O so they should not block.  There is a
>>higher priority thread that occasionally wakes up and reports the runers'
>>progress.
>>
>>According to both the Java and Win32 documentation, thread scheduling
>>is done only among those threads that are at the  highest
>>priority level of all currently runnable threads.  Thus, if you
>>set the runners to different priorities, the lower priority
>>runner should be "starved out" until the higher one finishes.
>>This is clearly not happening when I run the applet in Windows 95.
>>Although the higher priority runner always wins by a large margin,
>>the lower priority thread manages to butt in every once in awhile and
>>bump its count a few ticks.
>>
>>This behavior is contrary to both the Java and the Win32 specs.  Does
>>anybody know what's going on?  (I did discover that the 10 Java 
>>priorities are mapped to only 6 Win32 priorities and I am
>>definitely assigning different Win32 priorities to the runners,
>>so it has nothing to do with that.)
>
>Not sure about java scheduling, but as far as Win32 stuff goes I think you 
can 
>only ever set the base priority level of a thread - the dynamic priority 
>(which is actually the one used for scheduling) is assigned by the system 
>based upon several factors, including things like total CPU use and time 
since 
>last timeslice ...? ... or something like that.
>This ould explain the bahaviour you see - the higher priority racer gets most 
>CPU, but as it does so it's dynamic priority is reduced and the dynamic 
>priority of the 'tortoise' thread is increased allowing it to occasionally 
get 
>a timeslice.
>
>Anyone else care to add to - or refute - any of the above? 
> 
>Matt.
>--
>Matt Stupple  -  stupplem@logica.com  -  http://www.logica.com/
>Logica UK Ltd, 75 Hampstead Rd NW1 2PL, +44(0)1716379111
>Words, thoughts and ideas all my own.
>

This certainly makes sense out of the behavior I'm seeing.  If this
is true then there is no way in Win32 to "starve" a lower priority
process??   It seems that there should be.

 

-- 
------------------------------------------------
David Strauss
E-mail: dstrauss@.panix.com 
        dstrauss@lehman.com 
-------------------------------------------------

-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post