How to make Atomic timer callback?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I’m using a timer, and when the timer is invoking my callback; I want that
the callback code will be executed at once as a one atomic action so the CPU
will not leave this tread in the middle of the callback execution.

Can anybody tell me how to it?
 
You can't prevent a user thread being preempted by the OS scheduler.

Willy.
 
Isn't there a way to make sure that a set of calls will be excuted before the
CPU leaves?
 
Only device drivers get this kind of power.

If user mode code could do this, it would be able to freeze the system up
completely. Imagine what would happen if your code asked for this an then
entered a loop that never finishes. The CPU would now be stuck in here and
wouldn't be allowedd out, and your system would freeze up completely - it
would be unable to respond to any kind of user input.

Device drivers can do this, but shouldn't obviously... But as anyone who
has written device drivers will tell you, it's relatively easy to end up
completely freezing up the system if you have certain kinds of bugs in your
driver. (No BSOD, just a sudden freeze where the mouse stops moving and the
system suddenly stops working.) You really don't want bugs in user-mode
code to be able to do this...
 
When your callback runs (on a thread - just like any other piece of code) it
consumes CPU time from it's allotted quota (max. 10 msec or 16 msec.).
That means your thread can only run for this max. quota, provided it isn't
pre-empted by the OS or it gives up it's quota as a result of a call-out (IO
call, Sleep or a Wait....)
Not sure what you mean with " a set of calls".

Willy.
 
When I say "a set of calls' I mean that the callback is calling some
functions, the functions may be within my code or Windows API.
 
Back
Top