There are 0-31 priority setting on windows nt thread.
what difference between them?
priority 10 is more cpu time than priority 11? how much ? 10% or what some
thing else?
This is a brief summary of the Win32 thread scheduler. Note that Microsoft
reserves the right to make changes to the algorithm at any time!
Threads can be assigned a priority between 0 (lowest) and 31 (highest). In
fact a thread priority is a combination of the process' priority class (from
IDLE_PRIORITY_CLASS to REALTIME_PRIORITY_CLASS) and the thread's relative
priority within the process (THREAD_PRIORITY_IDLE to
THREAD_PRIORITY_TIME_CRITICAL). A 'normal' thread in a 'normal' process
(i.e. where no change to the priority class or thread priority has taken
place) will usually have a priority of 8. Most processes should run at this
level. NT task manager runs at priority 13. Look at the platform SDK or MSDN
for more info...
The thread scheduler looks first for any threads at priority 31. If it finds
any then it assigns them a time-slice in a round-robin fashion until there
are no more priority 31 threads waiting to execute (i.e. they are all
'sleeping' or waiting for synchronisation objects etc.) The scheduler then
looks for priority 30 threads and so on.... If at any time a thread of a
higher priority than the one currently being serviced is ready to execute
the OS will pre-empt the current thread (suspend it) and assign a whole
time-slice to the higher priority thread.
You should therefore see how dangerous it can be if a badly behaved
application is set to run at a high priority (e.g. greater than 13 in NT).
If it enters a 'while(true);' loop then you could starve the system from
allowing any other tasks to get a timeslice (depending on what else is
running of course).
Just for information - you can also play tricks such as boosting the time
slice for the foreground application or temporarily boosting timeslice and
priority for any application. See SetProcessPriorityBoost(..) and
SetThreadPriorityBoost(..) for details.
Hope this helps...
NP
CUCOO wrote in message <7c0e8v$dne$1...@netnews.csie.NCTU.edu.tw>...