Is there a way to synch timers across processes?
An app consists of a GUI + 4 drivers. Each driver
must talk to its hardware in it’s unique 20ms interval,
over a 80 ms cycle. The drivers are identical
except for a node id.
The following code snippet doesn’t quite work
(using the Pentium’s built-in cycle counter as
a way of determining a unique 20ms slot).
This code is executed by each individual driver
process. The GUI launches the drivers at startup
(up to 4) 200ms apart.
/*Syncronise to the internal CPU clock, to a 80ms cycle and
then to a 20ms cycle in the 80ms based on the node id
This is to synchronise multiples /
timer.it_value.tv_sec = 0;
timer.it_value.tv_nsec = DELTAMILLISECONDS;
timer.it_interval.tv_sec = 0;
timer.it_interval.tv_nsec = DELTA*MILLISECONDS;
calibrate_rdtsc();
time32 = rdtsc32() % cycles_per_100_msec;
/*Wait for timer under 1 ms in a 100ms cycle first */
while (time32 > cycles_per_20_msec/20) {
time32 = rdtsc32() % cycles_per_100_msec;
}
/*here if cycle is at the start of a 100 ms cycle */
/now wait until the multiple of 20ms occurs /
while ((time32 <= (cycles_per_20_msecnode_id - cycles_per_20_msec/20))
||
(time32 >= (cycles_per_20_msecnode_id
Another approach would be to use a process just to do
the synchronisation and use a Trigger to synch the
other processes. Just wondering if there was a way
to do it by using the timers…
“Alex/Systems 104” <acellarius@yah0o.lsd.com> wrote in message
news:op.st7qutojbinb6v@alex-pentium-m…
Is there a way to synch timers across processes?
An app consists of a GUI + 4 drivers. Each driver
must talk to its hardware in it’s unique 20ms interval,
over a 80 ms cycle. The drivers are identical
except for a node id.
I`m confuse, you asking “across processes” but then you mention “node id”.
Are processes on the same node or on different nodes.
If they are on the same node you could try using TIMER_ABS (an absolute
time) to get the the first firing to occurs at a specific time (using the
node id to create the time) then the interval would take care of the rest.
If you are on different node, I doubt that`s possible.
The following code snippet doesn’t quite work
(using the Pentium’s built-in cycle counter as
a way of determining a unique 20ms slot).
This code is executed by each individual driver
process. The GUI launches the drivers at startup
(up to 4) 200ms apart.
/*Syncronise to the internal CPU clock, to a 80ms cycle and
then to a 20ms cycle in the 80ms based on the node id
This is to synchronise multiples /
timer.it_value.tv_sec = 0;
timer.it_value.tv_nsec = DELTAMILLISECONDS;
timer.it_interval.tv_sec = 0;
timer.it_interval.tv_nsec = DELTA*MILLISECONDS;
calibrate_rdtsc();
time32 = rdtsc32() % cycles_per_100_msec;
/*Wait for timer under 1 ms in a 100ms cycle first */
while (time32 > cycles_per_20_msec/20) {
time32 = rdtsc32() % cycles_per_100_msec;
}
/*here if cycle is at the start of a 100 ms cycle */
/now wait until the multiple of 20ms occurs /
while ((time32 <= (cycles_per_20_msecnode_id - cycles_per_20_msec/20))
||
(time32 >= (cycles_per_20_msecnode_id +
cycles_per_20_msec/20))) {
time32 = rdtsc32() % cycles_per_100_msec;
}
timer_settime( timer_id, 0, &timer, NULL );
Another approach would be to use a process just to do
the synchronisation and use a Trigger to synch the
other processes. Just wondering if there was a way
to do it by using the timers…
On Wed, 20 Jul 2005 17:09:55 +0400, Alex/Systems 104 acellarius@yah0o.lsd.com> > wrote:
Is there a way to synch timers across processes?
How do you handle the (inevitable) XTALL frequency difference between
the nodes? Even if you could get the proper syncronizm - it WILL drift
apart soon…
Sorry about the confusing nomenclature.
The application runs on a single x86 processor,
using a customer Arcnet driver. Hence
the node id, but that has nothing to do with
native networking node id’s…
“Alex/Systems 104” <> acellarius@yah0o.lsd.com> > wrote in message
news:op.st7qutojbinb6v@alex-pentium-m…
Is there a way to synch timers across processes?
An app consists of a GUI + 4 drivers. Each driver
must talk to its hardware in it’s unique 20ms interval,
over a 80 ms cycle. The drivers are identical
except for a node id.
I`m confuse, you asking “across processes” but then you mention “node
id”.
Are processes on the same node or on different nodes.
Sorry about the confusing nomenclature.
See other post for correction.
If they are on the same node you could try using TIMER_ABS (an absolute
time) to get the the first firing to occurs at a specific time (using the
node id to create the time) then the interval would take care of the
rest.
If you are on different node, I doubt that`s possible.
All one node.
Thanks Mario, good idea.
Abs time say at the next second.
1st when the timer occurs, relative timer at
the desired interval, with a unique 20ms multiple
offset…