Re: SetPriority() Question
- From: David Schwartz <davids@xxxxxxxxxxxxx>
- Date: 24 May 2007 21:34:26 -0700
On May 19, 12:53 pm, Green <myflame...@xxxxxxxxxxx> wrote:
Although I changed proc1's priority to P_VERY_LOW but increased
proc2's, I didn't get the output that I expected as the followings:
Process two is running.
Process one is running.
Probably because process one was 100% complete before process two even
started.
Could anyone correct me please ? Thanks a lot in advance!!!
There is nothing to correct except your expectations. Priorities do
not force ordering and only apply to situations where there is
contention for CPU resources.
One thing that *might* help is raising the priority of the process
that creates the other two processes so that it is more likely to
create both processes before either runs to completion. But priorities
are not the guarantees you seem to expect them to be.
For one thing, priorities don't apply when one process hits a page
fault. A lower-priority process may get the CPU because the higher-
priority process can't make forward progress at that instant. Also, if
you have more than one CPU, more than one process will run at a time.
The problem is entirely in your expectations. You cannot use
priorities to enforce ordering, and much code that has tried to do so
has broken.
DS
.
- References:
- SetPriority() Question
- From: Green
- SetPriority() Question
- Prev by Date: Re: Building portable GUI applications
- Next by Date: Re: how to diagnose wierd random crashes/"memory clobbering"
- Previous by thread: Re: SetPriority() Question
- Next by thread: Network resilience.
- Index(es):
Relevant Pages
|