473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to make Atomic timer callback?

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?

--
Regards
Sharon G.
Nov 16 '05 #1
5 4074
You can't prevent a user thread being preempted by the OS scheduler.

Willy.

"Sharon" <Sh****@discussions.microsoft.com> wrote in message
news:C3**********************************@microsof t.com...
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?

--
Regards
Sharon G.

Nov 16 '05 #2
Isn't there a way to make sure that a set of calls will be excuted before the
CPU leaves?

------
Regards
Sharon G.
Nov 16 '05 #3
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...
--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/

"Sharon" wrote:
Isn't there a way to make sure that a set of calls will be excuted before
the
CPU leaves?

Nov 16 '05 #4
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.

"Sharon" <Sh****@discussions.microsoft.com> wrote in message
news:10**********************************@microsof t.com...
Isn't there a way to make sure that a set of calls will be excuted before
the
CPU leaves?

------
Regards
Sharon G.

Nov 16 '05 #5
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.
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: The Beast | last post by:
I'm trying to create a thread to write to the serial port and I keep getting an odd error cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)(void *)' and...
8
by: bearophileHUGS | last post by:
Hello, I have four things to ask or to suggest, sorry if they seem basic or already discussed. ------------------- I am still ignorant about Tkinter. This little program, after pressing the...
5
by: Richard P | last post by:
I need some help on timers. My app is asp.net 1.1 website running in a shared hosting environment with a third-party service provider. I currently request and cache 20 - 40 remote RSS feeds. When a...
4
by: Todd | last post by:
I have an ASP.NET application and I would like to have some code run on the server automatically once a day at a specified time. I create a timer thread to call a simple callback in the...
1
by: logdenav | last post by:
Hello I'm testing the performance of the System.Timers.Timer class. I created a small program that create 100 User objects. Each USer object create a MyTimer object. The constructor of the User...
0
by: bg_ie | last post by:
Hi all, I'm writing a .net Com object to read messages from an external bus. Also, under certain situations, I output messages to the bus in order to generate bus load, for testing purposes. An...
4
by: jwriteclub | last post by:
Hello all, I have a quick question about timers in C#. I have a System.Windows.Forms.Timer timer (the kind you "drag" out of the toolbox. It looks something like this: public class...
7
by: genesistr | last post by:
Hi, I have timer class and some classes use timer. but when i come back from timer with callback function, i can see this. properties. function Timer(dName, dCallback){ this.timer = null;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.