High speed realtime in QNX

We are considering using QNX for a digital servo controller. We need servo
update rates of 600Hz to 1000Hz. We were hoping to set up a periodic timer
to trigger these process. We setup a simple experiment where we toggle a bit
on the parallel port and watch it with a o-scope.
We cannot get this process to run repeatably even at 500Hz (one cycle every
2ms). Every once in a while the process will wait 3ms before executing. We
have made a custom image of the OS and our process is really the only thing
running and has highest priority.
I’m hoping that I’m doing something wrong. I saw a demo of Embeddix about a
year ago and they were running a process at 300 KHz. They were doing
pulse-width modulation by simply toggling a bit on the parrallel port. That
pin of the parallel port was connected to ground through a coil of wire.
They had a short wave radio tuned to 150 KHz and the computer would play a
melody by generating a PWM waveform that was received by the receiver. You
could stop the process or disconnect the parallel port and the sound would
stop, so I don’t think this was any kind of hoax.
Does QNX give me any mechanism for executing such high-speed periodic
process, or am I forced to design a hardware clock to interrupt me at the
rate I desire.

Any advice is much appreciated.

“Chris Rose” <esorcc@hotmail.com> wrote in message
news:a2k3s6$qv2$1@inn.qnx.com

We are considering using QNX for a digital servo controller. We need servo
update rates of 600Hz to 1000Hz. We were hoping to set up a periodic timer
to trigger these process. We setup a simple experiment where we toggle a
bit
on the parallel port and watch it with a o-scope.
We cannot get this process to run repeatably even at 500Hz (one cycle
every
2ms). Every once in a while the process will wait 3ms before executing. We
have made a custom image of the OS and our process is really the only
thing
running and has highest priority.
I’m hoping that I’m doing something wrong. I saw a demo of Embeddix about
a
year ago and they were running a process at 300 KHz. They were doing
pulse-width modulation by simply toggling a bit on the parrallel port.
That
pin of the parallel port was connected to ground through a coil of wire.
They had a short wave radio tuned to 150 KHz and the computer would play a
melody by generating a PWM waveform that was received by the receiver. You
could stop the process or disconnect the parallel port and the sound would
stop, so I don’t think this was any kind of hoax.
Does QNX give me any mechanism for executing such high-speed periodic
process, or am I forced to design a hardware clock to interrupt me at the
rate I desire.

I’ve done 1000Hz, (on SMP machine though) and for as long as
we could observit (weeks) it NEVER missed one beat.

Check out http://qdn.qnx.com/articles/oct3100/concept_of_time.html
That may be the cause of your problem.

Further more make sure you process is running at maximum priority
and the pulse (assuming it’s a pulse) attached to the timer is
set at maximum priority as well.


Any advice is much appreciated.

1000Hz would is right at the 1ms timer resolution it’s hard to believe that
it never missed. How did you observe and monitor it?
Still having to use and SMP machine just to run a process at 1kHz seems to
be throwing a lot of hardware at a problem, especially when this OS is
supposedly designed for embedded systems.
The demo I saw on embeddix was running on a single processor 750MHz machine.
I don’t mean to sound like I’m slamming QNX. I just want to know will it do
high speed realtime periodic processes well, or do I need to design a
hardware clock, or go to a different OS.


“Mario Charest” <goto@nothingness.com> wrote in message
news:a2k6o0$t2u$1@inn.qnx.com

“Chris Rose” <> esorcc@hotmail.com> > wrote in message
news:a2k3s6$qv2$> 1@inn.qnx.com> …
We are considering using QNX for a digital servo controller. We need
servo
update rates of 600Hz to 1000Hz. We were hoping to set up a periodic
timer
to trigger these process. We setup a simple experiment where we toggle a
bit
on the parallel port and watch it with a o-scope.
We cannot get this process to run repeatably even at 500Hz (one cycle
every
2ms). Every once in a while the process will wait 3ms before executing.
We
have made a custom image of the OS and our process is really the only
thing
running and has highest priority.
I’m hoping that I’m doing something wrong. I saw a demo of Embeddix
about
a
year ago and they were running a process at 300 KHz. They were doing
pulse-width modulation by simply toggling a bit on the parrallel port.
That
pin of the parallel port was connected to ground through a coil of wire.
They had a short wave radio tuned to 150 KHz and the computer would play
a
melody by generating a PWM waveform that was received by the receiver.
You
could stop the process or disconnect the parallel port and the sound
would
stop, so I don’t think this was any kind of hoax.
Does QNX give me any mechanism for executing such high-speed periodic
process, or am I forced to design a hardware clock to interrupt me at
the
rate I desire.


I’ve done 1000Hz, (on SMP machine though) and for as long as
we could observit (weeks) it NEVER missed one beat.

Check out > http://qdn.qnx.com/articles/oct3100/concept_of_time.html
That may be the cause of your problem.

Further more make sure you process is running at maximum priority
and the pulse (assuming it’s a pulse) attached to the timer is
set at maximum priority as well.


Any advice is much appreciated.
\

Rest assured that QNX should be able to meet your requirements quite nicely.

I don’t think you read the reference that Mario gave you. It explains that
because of the PC’s crystal frequency, the timer interrupt is not exactly 1
ms. However, the OS keeps track of these differences and adjusts things so
that your long-range timing will be right on. This causes an occasional
“skip” of an expected timer fulfillment. The solution is very simple, set
your timer interval to 999847 ns, rather than 1 ms.

However, since you are seeing a 3 ms blip, rather than 2 ms that would be
expected from the previous explanation, there must be something else going
on. Do you have any file or console I/O from your program? Is the system on
a network? Is Photon running? What priority is your program?

Perhaps you’d like to share the source code to a simple test case with us so
we can help resolve the issue.

Marty Doane
Siemens Dematic

“Chris Rose” <esorcc@hotmail.com> wrote in message
news:a2k763$7p$1@inn.qnx.com

1000Hz would is right at the 1ms timer resolution it’s hard to believe
that
it never missed. How did you observe and monitor it?
Still having to use and SMP machine just to run a process at 1kHz seems to
be throwing a lot of hardware at a problem, especially when this OS is
supposedly designed for embedded systems.
The demo I saw on embeddix was running on a single processor 750MHz
machine.
I don’t mean to sound like I’m slamming QNX. I just want to know will it
do
high speed realtime periodic processes well, or do I need to design a
hardware clock, or go to a different OS.


“Mario Charest” <> goto@nothingness.com> > wrote in message
news:a2k6o0$t2u$> 1@inn.qnx.com> …

“Chris Rose” <> esorcc@hotmail.com> > wrote in message
news:a2k3s6$qv2$> 1@inn.qnx.com> …
We are considering using QNX for a digital servo controller. We need
servo
update rates of 600Hz to 1000Hz. We were hoping to set up a periodic
timer
to trigger these process. We setup a simple experiment where we toggle
a
bit
on the parallel port and watch it with a o-scope.
We cannot get this process to run repeatably even at 500Hz (one cycle
every
2ms). Every once in a while the process will wait 3ms before
executing.
We
have made a custom image of the OS and our process is really the only
thing
running and has highest priority.
I’m hoping that I’m doing something wrong. I saw a demo of Embeddix
about
a
year ago and they were running a process at 300 KHz. They were doing
pulse-width modulation by simply toggling a bit on the parrallel port.
That
pin of the parallel port was connected to ground through a coil of
wire.
They had a short wave radio tuned to 150 KHz and the computer would
play
a
melody by generating a PWM waveform that was received by the receiver.
You
could stop the process or disconnect the parallel port and the sound
would
stop, so I don’t think this was any kind of hoax.
Does QNX give me any mechanism for executing such high-speed periodic
process, or am I forced to design a hardware clock to interrupt me at
the
rate I desire.


I’ve done 1000Hz, (on SMP machine though) and for as long as
we could observit (weeks) it NEVER missed one beat.

Check out > http://qdn.qnx.com/articles/oct3100/concept_of_time.html
That may be the cause of your problem.

Further more make sure you process is running at maximum priority
and the pulse (assuming it’s a pulse) attached to the timer is
set at maximum priority as well.


Any advice is much appreciated.


\

Chris Rose wrote:

1000Hz would is right at the 1ms timer resolution it’s hard to believe that
it never missed. How did you observe and monitor it?

I have done 5Khz sampling with 100% accuracy on QNX4 (measured over
days). QNX6 is not as fast as QNX4, since it is not optimized for a
single processor (as QNX4 is), still, I can easily believe Mario’s
assertion that QNX6 can do 1Khz reliably, in fact, I would be willing to
bet that it could be done without SMP.

Still having to use and SMP machine just to run a process at 1kHz seems to
be throwing a lot of hardware at a problem, especially when this OS is
supposedly designed for embedded systems.

QNX6 is built for the future of embedded systems. QSSL obviously sees a
non-uniprocessor world, with plenty of available horsepower (relative to
now). If this is a reasonable view of the future, then QNX6 is a
reasonable answer. If you want maximum performance today on an x86
based platform, then QNX4 might be your answer. If you write your code
correctly, it should be a relatively painless port to QNX6 when the
embedded hardware of your choice catches up, and you then get
multi-processor capability for free.


The demo I saw on embeddix was running on a single processor 750MHz machine.
I don’t mean to sound like I’m slamming QNX. I just want to know will it do
high speed realtime periodic processes well, or do I need to design a
hardware clock, or go to a different OS.

QNX6 doesn’t do high-speed periodic processes as fast as I would like
(with system timer services) but I believe it is certainly capable of
doing what you are asking of it.

“Chris Rose” <esorcc@hotmail.com> wrote in message
news:a2k763$7p$1@inn.qnx.com

1000Hz would is right at the 1ms timer resolution it’s hard to believe
that
it never missed. How did you observe and monitor it?

It was logged in a file and measure by using the CPU counter, precise to
the CPU clock 500Mzh in that case. The files was then transfer over
windows to be plotted by MathLab. Using CPU counter is so precise we
could see the effect of the CPU cache…

Still having to use and SMP machine just to run a process at 1kHz seems to
be throwing a lot of hardware at a problem, especially when this OS is
supposedly designed for embedded systems.

An SMP machine was use because the task to perform every 1ms took
around 999us… Hence stuff like TCP/IP, data logging, photon, would
have no time left to run. By using SMP that solved the problem.

The demo I saw on embeddix was running on a single processor 750MHz
machine.
I don’t mean to sound like I’m slamming QNX. I just want to know will it
do
high speed realtime periodic processes well, or do I need to design a
hardware clock, or go to a different OS.

Take the time to read the article I pointed out.

  • Mario “not being read” Charest

“Rennie Allen” <rallen@csical.com> wrote in message
news:3C4DA7FB.6090808@csical.com

Chris Rose wrote:


I have done 5Khz sampling with 100% accuracy on QNX4 (measured over
days). QNX6 is not as fast as QNX4, since it is not optimized for a
single processor (as QNX4 is),

??? There are two versions of the kernel, one for single and one for
multi processors, There must be another reason why it’s not as fast :wink:))

Of course some driver may have to protect criticals section when
they don’t have too on single CPU, but being multi-threaded that
requirement exists anyway.

  • Mario

“Mario Charest” <goto@nothingness.com> wrote in message
news:a2k9k3$254$1@inn.qnx.com

“Rennie Allen” <> rallen@csical.com> > wrote in message
news:> 3C4DA7FB.6090808@csical.com> …
Chris Rose wrote:


I have done 5Khz sampling with 100% accuracy on QNX4 (measured over
days). QNX6 is not as fast as QNX4, since it is not optimized for a
single processor (as QNX4 is),

??? There are two versions of the kernel, one for single and one for
multi processors, There must be another reason why it’s not as fast > :wink:> ))

Mario, I think they meant that Watcom was optimized for X86. While GNU is

not optimized at all.


Bill Caroselli – 1(626) 824-7983
Q-TPS Consulting
QTPS@EarthLink.net

“Mario Charest” <goto@nothingness.com> wrote in message
news:a2k9fq$24n$1@inn.qnx.com

An SMP machine was use because the task to perform every 1ms took
around 999us… Hence stuff like TCP/IP, data logging, photon, would
have no time left to run. By using SMP that solved the problem.

On what?!

I’m not thrilled with RTP perfor


Bill Caroselli – 1(626) 824-7983
Q-TPS Consulting
QTPS@EarthLink.net

Chris Rose <esorcc@hotmail.com> wrote:

We are considering using QNX for a digital servo controller. We need servo
update rates of 600Hz to 1000Hz. We were hoping to set up a periodic timer
to trigger these process. We setup a simple experiment where we toggle a bit
on the parallel port and watch it with a o-scope.
We cannot get this process to run repeatably even at 500Hz (one cycle every
2ms). Every once in a while the process will wait 3ms before executing. We
have made a custom image of the OS and our process is really the only thing
running and has highest priority.

How did you write your test program? Doing it wrong will make things
worse.

Also, did you modify (decrease) the ticksize (clock resolution) on the QNX
box you were testing on?

Try something like:

new.nsec = 500000; /* 500 thousand nsec = 1/2 msec */
new.fract = 0;

ClockPeriod( CLOCK_REALTIME, &new, NULL, 0 );

SIGEV_PULSE_INIT( &ev, …);
timer_create( CLOCK_REALTIME, &ev, &timerid );
itime.it_value.tv_sec = 0;
itime.it_value.tv_nsec = 500000;
itime.it_interval.tv_sec = 0;
itime.it_interval.tv_nsec = 500000;

timer_settime( timerid, 0, &itime, NULL );

while(1)
MsgReceivePulse()
/* hit hardware */

This should give you an unblock at a rate just under 1/2 msec, except
that occasionally you will see an instance that is just under 1 msec.
(That is because the fundamental time source doesn’t give exactly 1/2
msec, it gives just under 1/2 msec…so if you ask for 1/2 msec, after
the error has accumulated, you will get a gap of 2 clock ticks, to
bring you back into sync.)

To go much faster than this, you may want to look at some other mechanism.
(Your own hardware timer, using one of the other timers on the timer chip
on an x86 or something else. The reason for this, is that the OS does
some work on each timer tick and you may not want that extra overhead.
Depends on how powerful your CPU is.)

-David

QNX Training Services
I do not answer technical questions by email.

“Bill Caroselli” <qtps@earthlink.net> wrote in message
news:a2ka1n$2gm$1@inn.qnx.com

“Mario Charest” <> goto@nothingness.com> > wrote in message
news:a2k9fq$24n$> 1@inn.qnx.com> …

An SMP machine was use because the task to perform every 1ms took
around 999us… Hence stuff like TCP/IP, data logging, photon, would
have no time left to run. By using SMP that solved the problem.

On what?!

Bill I don’t understand the question. On what what? :wink:

I’m not thrilled with RTP perform

Me neither, QNX4 definitely feels much faster.
But that’s on day to day usage as a development machine.
gcc doesn’t help give an impression of speed. The performance
of Phindows (which I use all the time) is much slower on QNX6 as
well.

I have been thinking of running a benchmark that consists of assembly
code , that wouldn’t make no system or library call. That would
remove the compiler and libraries out of the equation.


Bill Caroselli – 1(626) 824-7983
Q-TPS Consulting
QTPS@EarthLink.net

That was strange. It lost of my post.

What I was saying/asking is that I think that RTP can easily do 1000
interrupts per second and do a small amount of work on eack interrupt and
still have plenty of CPU cycles left over for the rest of the system.


Bill Caroselli – 1(626) 824-7983
Q-TPS Consulting
QTPS@EarthLink.net


“Mario Charest” <goto@nothingness.com> wrote in message
news:a2kh18$7d9$1@inn.qnx.com

“Bill Caroselli” <> qtps@earthlink.net> > wrote in message
news:a2ka1n$2gm$> 1@inn.qnx.com> …
“Mario Charest” <> goto@nothingness.com> > wrote in message
news:a2k9fq$24n$> 1@inn.qnx.com> …

An SMP machine was use because the task to perform every 1ms took
around 999us… Hence stuff like TCP/IP, data logging, photon,
would
have no time left to run. By using SMP that solved the problem.

On what?!

Bill I don’t understand the question. On what what? > :wink:


I’m not thrilled with RTP perform

Me neither, QNX4 definitely feels much faster.
But that’s on day to day usage as a development machine.
gcc doesn’t help give an impression of speed. The performance
of Phindows (which I use all the time) is much slower on QNX6 as
well.

I have been thinking of running a benchmark that consists of assembly
code , that wouldn’t make no system or library call. That would
remove the compiler and libraries out of the equation.

\

Bill Caroselli – 1(626) 824-7983
Q-TPS Consulting
QTPS@EarthLink.net

\

Mario Charest wrote:

single processor (as QNX4 is),

My fault, I should have typed “single processor architecture”.

??? There are two versions of the kernel, one for single and one for
multi processors, There must be another reason why it’s not as fast > :wink:> ))

I meant that QNX4 was optimized for the x86 architecture. QNX4 has
faster context switches on an equivalent x86 machine than QNX6 does.
This is mostly due to use of “tricks” that only work on the x86
architecture, and hence QNX6 can’t use (since it is multi-architecture).

Of course other processor architectures may have even better “tricks”
than the x86, but implementing these would essentially mean writing a
different kernel for each processor architecture, and perhaps even
generating different executable formats for different platforms in order
to enable these tricks.

“Rennie Allen” <rallen@csical.com> wrote in message
news:3C4DDF21.2050706@csical.com

Mario Charest wrote:

single processor (as QNX4 is),

My fault, I should have typed “single processor architecture”.

??? There are two versions of the kernel, one for single and one for
multi processors, There must be another reason why it’s not as fast
:wink:> ))

I meant that QNX4 was optimized for the x86 architecture. QNX4 has
faster context switches on an equivalent x86 machine than QNX6 does.
This is mostly due to use of “tricks” that only work on the x86
architecture, and hence QNX6 can’t use (since it is multi-architecture).

Of course other processor architectures may have even better “tricks”
than the x86, but implementing these would essentially mean writing a
different kernel for each processor architecture, and perhaps even
generating different executable formats for different platforms in order
to enable these tricks.

http://www.qnx.com/news/pr/aug21_00-pent.html

  • Mario

Chris Rose <esorcc@hotmail.com> ÐÉÛÅÔ ×
ÓÏÏÂÝÅÎÉÉ:a2k3s6$qv2$1@inn.qnx.com

We are considering using QNX for a digital servo controller. We need servo
update rates of 600Hz to 1000Hz. We were hoping to set up a periodic timer
to trigger these process. We setup a simple experiment where we toggle a
bit
on the parallel port and watch it with a o-scope.
We cannot get this process to run repeatably even at 500Hz (one cycle
every
2ms). Every once in a while the process will wait 3ms before executing. We

Try to use TealTime Linux. On I486 DX4-100 I get process to run repeatably
even at 20 000 Hz.

??? There are two versions of the kernel, one for single and one for
multi processors, There must be another reason why it’s not as fast
:wink:> ))

Mario, I think they meant that Watcom was optimized for X86. While GNU is
not optimized at all.

I tested Watcom and GCC for dos32 on digital filters and get similar
results.

I meant that QNX4 was optimized for the x86 architecture. QNX4 has

Optimized for architecture can be only task swicher.
Example: in ucos-ii (www.ucos-ii.com) only task swicher “processor depend”.

After doing some benchmarks, I can say that the code quality
generated by gcc is not bad at all. Sometimes it’s simply
better then watcom especially in floating point arithmetic.
But the system libraries seem to be not optimized at all.
For example, try simple new/delete loop. In my case exe
produced by gcc was 4 times slower then wc’s one!

For those who are interested in benchmarking there is Bench++
suite which is free.

cheers,
Igor

I’m not thrilled with RTP perform

Me neither, QNX4 definitely feels much faster.
But that’s on day to day usage as a development machine.
gcc doesn’t help give an impression of speed. The performance
of Phindows (which I use all the time) is much slower on QNX6 as
well.

I have been thinking of running a benchmark that consists of assembly
code , that wouldn’t make no system or library call. That would
remove the compiler and libraries out of the equation.

Mario Charest wrote:


http://www.qnx.com/news/pr/aug21_00-pent.html

I don’t know if this refers to tricks, so much as access to some
undocumented features of the PIII.

“Rennie Allen” <rallen@csical.com> wrote in message
news:3C4EEB8D.8030104@csical.com

Mario Charest wrote:



http://www.qnx.com/news/pr/aug21_00-pent.html

I don’t know if this refers to tricks, so much as access to some
undocumented features of the PIII.

Doesn’t matter, that tells me kernel is tuned for a perticular (most
probably
for each) architecture.