threads

  • Thread starter Thread starter csharpula csharp
  • Start date Start date
C

csharpula csharp

Can someone please help me with the following question:
Describe one or more situations in which a lower-priority thread is
running whereas a higher priority thread is not?
 
but can u explain the the mechanizm of it,who is responsible to let the
lower priority thread to run and how?
thanks
 
There's a simple starvation pattern that goes something like this:
Higher priority thread executes and blocks waiting for a resource. Lower
priority thread gets cpu time and performs to completion because it contains
the reference higher priority thread is waiting on.
 
csharpula said:
but can u explain the the mechanizm of it,who is responsible to let the
lower priority thread to run and how?

A high priority thread can't run if it's blocked on I/O or waiting for a
resource to come free. The operating system then chooses some other
thread to run.

-- Barry
 
In addition, everytime a schedulable thread doesn't get run, a counter is
incremented inside the OS. When that counter gets high enough, the thread
receives an automatic boost in priority and the counter is reset.
Eventually, even idle time (thread priority = 1) threads will become the
highest priority thread in the system and run for at least one thread
quantum. Note the counter increment value and the quantum of time for each
thread are OS dependent (as in different versions of Windows use different
numbers), nor are they documented outside MS.

Mike Ober.
 
Take a look at http://msdn2.microsoft.com/en-us/library/ms685096.aspx for a
series of articles describing the Windows thread scheduler, especially the
sections on Priority Boosts and Priority Inversion. Keep in mind that all
threads, whether they be generated directly via Win32 calls, the
system.Threading class, or the framework's thread pool must eventually be
scheduled via the windows thread scheduler.

Mike Ober.
 
.... if the Windows Balance Set Manager has detected something funny and is
fixing it.

.... if the high priority thread has voluntarily given up it's timeslice
(Sleep).

.... if the high priority thread is blocked.

... if you have multiple processors and/or cores, it's all out the window
anyway.
 
Back
Top