Synchronisation with QNX?

Hi!

I’m actually working with Windows NT4 but I got problems because it’s not
real time when I ask , for example, to read 64 bits from a file (fread)
every 5 microseconds…

Is it possible to do that with QNX?
Is there any C or C++ function that allow to synchronise a function in QNX??
Which compiler do I have to use? I heard about Watcom…

Sorry for my english and thanks for any help!

STARN

I don’t think you can “wake up” every 5 micro-seconds. But if you could, I
do think you could read 64 bits (i.e. 8 bytes) every 5 micro-seconds,
depending on what (device or filesystem) you were reading those bytes from.

Are you sure you mean MICRO seconds?

“arno stoum” <starn@yucom.be> wrote in message
news:aamnke$egv$1@inn.qnx.com

Hi!

I’m actually working with Windows NT4 but I got problems because it’s not
real time when I ask , for example, to read 64 bits from a file (fread)
every 5 microseconds…

Is it possible to do that with QNX?
Is there any C or C++ function that allow to synchronise a function in
QNX??
Which compiler do I have to use? I heard about Watcom…

Sorry for my english and thanks for any help!

STARN
\

Well, yes, it’s microseconds. It’s to simulate an input that receive 64 bits
at 192kHz (1/192000=5.33…microseconds).
Just simulate… so I can map a small file to memory in a buffer and read 64
bits every 5.33… microseconds.
But I just need to know if there is a function that do that or a other one
like sleep()…

Thanks in advance,

STARN

If you have device that can generate interrupts at 192KHz, then I don’t
know, maybe. But I don’t think you can use a QNX timer to get interrupted
at that rate.

There is also a nanosleep() function but that CPU loops to count off clock
cycles. Probably not what you want to do in a real time system.

“arno stoum” <starn@yucom.be> wrote in message
news:aan25i$lm6$1@inn.qnx.com

Well, yes, it’s microseconds. It’s to simulate an input that receive 64
bits
at 192kHz (1/192000=5.33…microseconds).
Just simulate… so I can map a small file to memory in a buffer and read
64
bits every 5.33… microseconds.
But I just need to know if there is a function that do that or a other one
like sleep()…

Thanks in advance,

STARN

Thanks a lot Bill,

I think I can maybe do something with the nanosleep() function. Is it
possible to work with threads in QNX or is it only for Windows?
You mean It’s not what I’m looking for because the sleep function may cause
a lack of performances from the CPU? And QNX is not going to be able to
respond within a fixed period of time? I really don’t know how it’s going to
run.

I’m trying to install the software packets but in doesn’t work really
good…

Anyway, thanks a lot for your help !

STARN

“Bill Caroselli (Q-TPS)” <QTPS@earthlink.net> wrote:

If you have device that can generate interrupts at 192KHz, then I don’t
know, maybe. But I don’t think you can use a QNX timer to get interrupted
at that rate.

There is also a nanosleep() function but that CPU loops to count off clock
cycles. Probably not what you want to do in a real time system.

nanosleep() is just a different interface to the timer code.

nanospin() is the CPU loop to wait for a short period of time.

Simulating something that happens at 192Khz is difficult, there isn’t
any problem reading data at that rate – the problem is getting something
to “wake you up” at that rate – the OS’s fundamental wake-up frequency
defaults to 1khz (every 1 milli-second). It can be configured to a
lower value, but that is limitted as well (I think .5 ms under currently
shipping versions, 6.2 will allow noticeably lower than .5 ms, but not
sure it will allow 5 us, though that might be the lower bounadary).

Usually, you need an external source of interrupts to do this. If you’re
on x86, you might be able to use one of the timers that the OS doesn’t
use. (If I remember correctly, the standard PC timer chip supplies
3 timers, timer 0 is used by the OS, timer 1 is used for sound generation
for beeps, timer 2 is unused. Be very careful, though, as different
bits in the same control register affect different timers. Don’t
accidentally disable timer 0, you won’t like what it does to your
system.)

Other hardware may have a programmable timer as well, or you may have
to find a hardware source of interrupts. Maybe a serial uart, set to
interrupt per byte, with data coming in at something close to the correct
rate?

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Thanks David for all this :slight_smile:

But for the moment I’m trying put some software on QNX but nothing work…
From the CD I downloaded, package manager goes inside the good directory,
tells me to choose the packets I want to install but there is no packets to
choose!!! I tried others directories but it tells me there is no repository
in the directory…
I tried www Repository but after 2 or 3 minutes showing it’s downloading
repository information, it tells me : " couldn’t resolv host
packages.qnx.com”"…

Do I have to use Watcom for C++?
Where can I find it? It’s on the CD?

Sorry for these newbies questions but it makes ten hours Im trying to
install all this and if I don’t find the way to do it, i’ll throw my
computer through the window…

Thanks!!!

STARN

If you ask nanosleep() to sleep for less than the current ticksize, does it
a. immediately return
b. wait till next clock tick (in keeping with posix), then return
c. call nanospin()

I guess I assumed C.

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:aaooj9$c4m$2@nntp.qnx.com

nanosleep() is just a different interface to the timer code.

nanospin() is the CPU loop to wait for a short period of time.

Hi Bill,

I really whish I could try your sollutions but I still don’t have any soft
on QNX !!!

This package installer is turning me crazy!!!

In the packages installer, when I push the “QNX CDRom repository " button,
a
window prompt to tell me " unable to acces repository” and “possible reason:
this location does not
contain a repository please ensure the URL is correct.”

I push on the “add " button and I insert this URL: /fs/cd0/. I click “done”
and I click on the new line I just created.
At this moment, the window of the package manager change and in the
description field, I can read " please select a package or a topic from the
tree on the left” BUT there is no tree!!!

Maybe it’s not the right URL or I have to reinstall everything…

Again, sorry for my english, I hope it’s possible to understand
me…

Thanks

STARN

%% “Bill Caroselli (Q-TPS)” <QTPS@EarthLink.net> writes:

bc> If you ask nanosleep() to sleep for less than the current ticksize, does it
bc> a. immediately return
bc> b. wait till next clock tick (in keeping with posix), then return
bc> c. call nanospin()

bc> I guess I assumed C.

Nope!

You actually answered your own question when you wrote “in keeping with
POSIX” :slight_smile:. QNX is aggressively POSIX.

Check the docs:

“The suspension time may be longer than requested because the
argument value is rounded up to be a multiple of the system timer
resolution …”

So, the answer is (b).

Paul D. Smith <pausmith@nortelnetworks.com> HASMAT–HA Software Mthds & Tools
“Please remain calm…I may be mad, but I am a professional.” --Mad Scientist

These are my opinions—Nortel Networks takes no responsibility for them.

I understand.

I’ve been installing QNX software for over 15 years. The more they automate
it the harder it gets. Boy, give me the good old *.tar.F files. Or even
*.tgz files if you want to be more windoze compatible.

I have several systems running QNX 6 and several other system I can’t get
the install to run on, just like you.

“arno stoum” <starn@yucom.be> wrote in message
news:aap9e6$brn$1@inn.qnx.com

Hi Bill,

I really whish I could try your sollutions but I still don’t have any soft
on QNX !!!

This package installer is turning me crazy!!!

In the packages installer, when I push the “QNX CDRom repository "
button,
a
window prompt to tell me " unable to acces repository” and “possible
reason:
this location does not
contain a repository please ensure the URL is correct.”

I push on the “add " button and I insert this URL: /fs/cd0/. I click
“done”
and I click on the new line I just created.
At this moment, the window of the package manager change and in the
description field, I can read " please select a package or a topic from
the
tree on the left” BUT there is no tree!!!

Maybe it’s not the right URL or I have to reinstall everything…

Again, sorry for my english, I hope it’s possible to understand
me…

Thanks

STARN


\

I was afraid of that. Then the obvious next question is does it return on
the very next timer tick, which may still be too soon, or the only after
that.

It sounds like nanosleep() is no better than delay() essentially. It just
does the divide for you.

“Paul D. Smith” <pausmith@nortelnetworks.com> wrote in message
news:p5g01blo0q.fsf@lemming.engeast.baynetworks.com

%% “Bill Caroselli (Q-TPS)” <> QTPS@EarthLink.net> > writes:

bc> If you ask nanosleep() to sleep for less than the current ticksize,
does it
bc> a. immediately return
bc> b. wait till next clock tick (in keeping with posix), then return
bc> c. call nanospin()

bc> I guess I assumed C.

Nope!

You actually answered your own question when you wrote “in keeping with
POSIX” > :slight_smile:> . QNX is aggressively POSIX.

Check the docs:

“The suspension time may be longer than requested because the
argument value is rounded up to be a multiple of the system timer
resolution …”

So, the answer is (b).

In fact, I just want to install gcc for the C++ and TCP/IP tools…

So you think I’m not going to be able to install them on my computer or I
just have to find the *.tgz files?

Thanks

STARN

I didn’t say that.

I just said I long for the simpler life of long ago when I got to type all
my commands in by hand from a text mode console.

“arno stoum” <starn@yucom.be> wrote in message
news:aape5p$fcg$1@inn.qnx.com

In fact, I just want to install gcc for the C++ and TCP/IP tools…

So you think I’m not going to be able to install them on my computer or I
just have to find the *.tgz files?

Thanks

STARN
\

And it’s not possible to do the same anymore?
With the *.qpk or *.qpm files?
Or if I find the gcc.tgz file or something like that…

What do you think I should do? I tried everything…

Now, I m downloading the 422Mb again and I’m going to reinstall QNX with a
new CD…
That’s the only thing I haven’t done yet…

I hope you’re going to tell me there is an other way or solution…

Thanks again…

STARN

“arno stoum” <starn@yucom.be> wrote in message
news:aapkgi$jih$1@inn.qnx.com

And it’s not possible to do the same anymore?
With the *.qpk or *.qpm files?

I don’t think so.

What do you think I should do? I tried everything…

Me too.

I hope you’re going to tell me there is an other way or solution…

Let me know if you find one. Sorry I can’t be of more help.

The only way that I have successfully installed RTP so far was to install
the 28 MB *.exe to windows first. But then it’s hosted by a Windows file
system.

GOT IT!!!

AFTER 2 DAYS…

There is a problem with my laptop!!! I read that somebody else had the
same problem one year ago…
I just copied the files from the repository directory of the CDROM to my
hard drive and I pointed the packet installer to this directory. But I
could only read 635 files from the CD directory instead of more than 1000…
I hope what I need is in there…

I downloaded an other 422Mb CD and I’ll try to know if it’s a problem of CD
or drive…

Thanks anyway a lot for your answers :slight_smile: (and ,again sorry for my
english…)

STARN

%% “Bill Caroselli (Q-TPS)” <QTPS@EarthLink.net> writes:

bc> I was afraid of that. Then the obvious next question is does it
bc> return on the very next timer tick, which may still be too soon,
bc> or the only after that.

It will never return before the interval you asked for.

It very well could return later than the interval you asked for.

If your clock tick is 5ms and you are 2ms from the next tick, and you
asked for a 4ms nanosleep(), then you wouldn’t wake up for 7ms (until
the tick after the next one), at the earliest.

Note it is impossible to tell the difference between returning late due
to clock tick granularity and returning late simply because some other
thread was running (unless you assume outside knowledge, like you are
the only thread running at the highest priority).

bc> It sounds like nanosleep() is no better than delay() essentially.
bc> It just does the divide for you.

nanosleep() is better than delay(), because nanosleep() is a POSIX
standard function and delay() is not.

Also, nanosleep() allows you to know how much time is left on your
requested interval if you are woken up early. This can be very
important, sometimes.

Other than that, yes, the only difference between them is that
nanosleep() takes its interval as a struct timespec (in nanoseconds)
while delay() takes its interval in milliseconds.

Paul D. Smith <pausmith@nortelnetworks.com> HASMAT–HA Software Mthds & Tools
“Please remain calm…I may be mad, but I am a professional.” --Mad Scientist

These are my opinions—Nortel Networks takes no responsibility for them.

Thank Paul. This has been very educational. I thought that both sleep()
and delay() were POSIX but I see now that you are right.

Actually I have my own time_n class that has a complete math library and
sleep-like routines that also do something like nanospin(), all based on
struct timespec.

“Paul D. Smith” <pausmith@nortelnetworks.com> wrote in message
news:p5y9f3jy31.fsf@lemming.engeast.baynetworks.com

%% “Bill Caroselli (Q-TPS)” <> QTPS@EarthLink.net> > writes:

bc> I was afraid of that. Then the obvious next question is does it
bc> return on the very next timer tick, which may still be too soon,
bc> or the only after that.

It will never return before the interval you asked for.

It very well could return later than the interval you asked for.

If your clock tick is 5ms and you are 2ms from the next tick, and you
asked for a 4ms nanosleep(), then you wouldn’t wake up for 7ms (until
the tick after the next one), at the earliest.

Note it is impossible to tell the difference between returning late due
to clock tick granularity and returning late simply because some other
thread was running (unless you assume outside knowledge, like you are
the only thread running at the highest priority).

bc> It sounds like nanosleep() is no better than delay() essentially.
bc> It just does the divide for you.

nanosleep() is better than delay(), because nanosleep() is a POSIX
standard function and delay() is not.

Also, nanosleep() allows you to know how much time is left on your
requested interval if you are woken up early. This can be very
important, sometimes.

Other than that, yes, the only difference between them is that
nanosleep() takes its interval as a struct timespec (in nanoseconds)
while delay() takes its interval in milliseconds.


Paul D. Smith <> pausmith@nortelnetworks.com> > HASMAT–HA Software Mthds &
Tools
“Please remain calm…I may be mad, but I am a professional.” --Mad
Scientist


These are my opinions—Nortel Networks takes no responsibility for
them.

%% “Bill Caroselli (Q-TPS)” <QTPS@EarthLink.net> writes:

bc> Actually I have my own time_n class that has a complete math
bc> library and sleep-like routines that also do something like
bc> nanospin(), all based on struct timespec.

Note that nanospin() and nanosleep() are very different, and you
should be careful to use the one you need.

nanosleep() releases the system to schedule another thread, because you
are saying that this thread doesn’t need the CPU any longer at the
moment. This thread will not be eligible to be scheduled again until
the sleep interval expires (or you’re woken up by a signal or
something).

nanospin() does NOT release your hold on the CPU; it is a busy spin
that is specifically calibrated to take a precise amount of time, much
less (potentially) than a tick. No other thread will be scheduled while
you are waiting for the spin interval to complete (not withstanding
higher priority thread issues); this is essentially completely wasted
resources. You should generally only use this if you have pretty
stringent, hard real-time requirements.

This is why it is not at all surprising (to me anyway :slight_smile:) that
nanosleep() for less than a tick doesn’t reduce to a nanospin(); that
would be very inappropriate since they are really quite different
things.

Paul D. Smith <pausmith@nortelnetworks.com> HASMAT–HA Software Mthds & Tools
“Please remain calm…I may be mad, but I am a professional.” --Mad Scientist

These are my opinions—Nortel Networks takes no responsibility for them.