Re: fixed time slices?
- From: "m" <m@xxx>
- Date: Tue, 26 Jun 2007 16:59:03 -0400
"Jan Bruns" <testzugang_janbruns@xxxxxxxx> wrote in message
news:468134af$0$20292$9b4e6d93@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
"m" <m@xxx>:
"Jan Bruns":
But the scheduler would also have the chance to let the hardware
generate
a timer-IRQ within wahtevr delay is desired. So it could put the CPU on
a ready low-priority thread for as long as a higher priority thread is
known to be unrunnable.
AFAIK the scheduler does not behave this way but if the scheduler planed
a
timer interrupt for a specific delay for the purpose of changing tasks
pre-emptivly, then that is just the end of the low-priority thread's time
slice. In this case, the scheduler would not detect that a higher
priority
thread was ready to run, but would _know_ that said thread would be ready
to
run and adjusted the time slices of other threads accordingly.
This example only makes sense in the case of simple Sleep(n) calls
because
the scheduler can only _know_ when a thread will become ready to run if
there is a fixed or known delay. Since even the relatively simple call
SleepEx(n, true) does not have a fixed or known delay, the scheduler
cannot
make any assumptions about how best to optimize the timer interrupts.
Combine this complexity with thousands of threads using tens of thousands
of
wait objects in much more complex ways than sleep (like WFMO and
Semaphores,
GQCS & IOCP, or Timer Queues) and it is easy to see why a fixed timer
interrupt interval would be the implementation of choice.
Shouldn't this be possible for any other event, too?
An event can only become signaled if the system sets it.
So the system would be able to directly call the scheduler,
whenever it signals an event. The scheduler would in turn
update it's timer, and decide wether to continue the thread
that raised the signalling, or to switch to a higher priority
thread that is yet runnable.
Yes the system does call the scheduler when a sync API is called but in
complex cases the scheduler cannot behave omnipotently.
Consider a relativly simple case where three threads are involved A, B, & C
with priorities low, med, & high respectively. Threads B & C are waiting on
a mutex and thread A running on CPU 1 signals it. The scheduler then runs,
detects thread C as ready to run and switches CPU 1 to thread C. Even if
there is a CPU 2 for thread B to run on, which might be executing a thread D
with even lower priority, there is no way to execute thread B immediately
without somehow signalling CPU 2 and by the time you did that CPU 2 might be
executing a higher priority thread than B. CPU 2 might also be scheduling
threads and detect thread B before you could signal it or it might be halted
waiting for work to do. There is no way to tell; and even if your could,
the information could be out of data before you could act on it.
This scheduling is further complicated by APCs (kernel & user), thread ideal
processors, affinity masks and NUMA architectures.
The short answer is that while it may seem trivial to say that the scheduler
should do something, the best you can do in windows is to set your thread
priorities (carefully) and assume that the scheduler will schedule your
threads some time close to when you want them to run; and you can improve
the precision of scheduler, at some performance cost, by using APIs like
TimeBeginPeriod.
.
- Follow-Ups:
- Re: fixed time slices?
- From: Jan Bruns
- Re: fixed time slices?
- References:
- fixed time slices?
- From: Jan Bruns
- Re: fixed time slices?
- From: Don Burn
- Re: fixed time slices?
- From: m
- Re: fixed time slices?
- From: Jan Bruns
- Re: fixed time slices?
- From: Jan Bruns
- Re: fixed time slices?
- From: m
- Re: fixed time slices?
- From: Jan Bruns
- Re: fixed time slices?
- From: m
- Re: fixed time slices?
- From: Jan Bruns
- Re: fixed time slices?
- From: m
- Re: fixed time slices?
- From: Jan Bruns
- fixed time slices?
- Prev by Date: Re: Folder timestamp
- Next by Date: USB Stuff
- Previous by thread: Re: fixed time slices?
- Next by thread: Re: fixed time slices?
- Index(es):
Relevant Pages
|