Thanks,
The following is the source code.
SetData(‘C’,Joint_Status,Joint_Tolk);/I/O /Access /Function/ is a
function to access I/O and it will take about 1.35ms.
/*************************************************************************
*****************************************************************/
timer_create(CLOCK_REALTIME, &event, &timer_id);
itime.it_value.tv_sec =0;
/* 1 million nsecs = .001 secs */
itime.it_value.tv_nsec =2000000;
itime.it_interval.tv_sec =0;
/* 1 million nsecs = .001 secs */
itime.it_interval.tv_nsec = 2000000;
timer_settime(timer_id, 0, &itime, NULL);
for(; {
rcvid = MsgReceive(chid, &msg, sizeof(msg), NULL);
if (rcvid == 0) { /* we got a pulse */
if (msg.pulse.code == MY_PULSE_CODE) {
SetData(‘C’,Joint_Status,Joint_Tolk);/*I/O /Access /Function/
//nanosleep();
} / else other pulses … /
} / else other messages … */
}
/***************************************************************************
***/
We set up a timer(2ms) in the program. In every time loop, the program
access
I/O port( real time communicate with another equipment). The result is the
timer
set up doesn’t work. The actual time loop is the communication time of I/O
port.
For example, if the time to access I/O port takes 1.3 ms every loop, the
elapsed
time of the timer loop become 1.3 ms no matter you set up timer as 1 ms, 2
ms
0r 3ms.
Yesterday, I try to put nanosleep() funtion in the loop. According to the
help file,
nanosleep() is used to suspend the thread until the signal comes. I set the
suspend
time as 0.1ms.
Tie Hu
“Bill Caroselli (Q-TPS)” <QTPS@EarthLink.net> wrote in message
news:aeoc9t$mh1$1@inn.qnx.com…
If the IO to your hardware takes longer than the period of your timer,
then
you won’t be able to execute your loop more often then the time it takes
to
access your hardware port.
(Did that make any sense? It was kind of like saying if 5 is bigger then
3
than 5 is bigger than 3.)
However, if, as you say, you tried a period greater than the time required
by your hardware access and it still repeats as often as the hardware
access
will allow, then I would guess that your not really waiting on the timer.
Is it possible that your setting the timer but not waiting for it?
Can you post a tiny snippet of code?
“tie” <> tie@cbis.ece.drexel.edu> > wrote in message
news:aeoap2$lp5$> 1@inn.qnx.com> …
We set up a timer(2ms) in the program. In every time loop,
the
program access
I/O port( real time communicate with another equipment). The result is
the
timer
set up doesn’t work. The actual time loop is the communication time of
I/O
port.
For example, if the time to access I/O port takes 1.3 ms every loop, the
elapsed
time of the timer loop become 1.3 ms no matter you set up timer as 1 ms,
2
ms
0r 3ms. If there is no I/O access in the loop, the timer works well. You
can
set up 1ms
,2ms, 0r 3ms.
Best Regard
Tie Hu
\