Re: software interrupt



Ron Eggler wrote:
I would like to write a timer application where i can call a function
every X milliseconds.

No problem, only that this is limited by the scheduling granularity, which
ranges from 1ms to 20ms (I think) for Linux. If what you want is feasible
also depends on whether a delay between the deadline and the according code
being called is fatal, i.e. what your realtime requirements are.

How far I am: I wrote an application that checks the
time since the last call and returns 1 when it's "ready" again so i can
issue a command like:

TimerStart(5); //every 5 seconds
while (1){
if (CheckTimer(5))
cout << "Great, 5 milliseconds have passed" << endl;
}

This works great but I would like to write something without the while(1)
loop [...]

Use a thread, e.g. boost::thread for a C++ program.

[...]i need to check more often than every 5 milliseconds.

In that case you have a hard realtime requirement, so you should get
acquainted to realtime programming. David already gave you a few pointers
how to tweak the scheduler.

One note though: both realtime programming and multithreaded programming
require a lot of understanding and good planning and thorough understanding
upfront. I guess you'll be up for a tough ride.


Uli

.