Is QNX too slow ???

Hello

I have a program ( quite a little one ) that was written using VC++ and then ported to QNX.
The program is TCP/IP server which should have 50~100 client & server socket connections and 100~200 threads to serve them. Client connection are used to update data from some devices and these updates must be done as soon as possible (it should take less than 50 ms for each update). Server connections just listen for some ports and are used to pass updated data to client or vice versa (clients ask QNX-server to write data to device). The problem is it works too slow, even slower than on Windows 2000 !! The main idea of porting the application to QNX was to increase update rate. But it’s not the only problem: when there is a lot of threads the program sometimes just terminates. The more threads the quicker this happens… Very strange considering that there was no behaviour like this on NT. And it doesn’t happens because main thread has terminated or something, it’s closed by OS.
Does anyone has any idea why all this may happen ?? I’m new in QNX programming and I’m really stuck with this.

Thanks.

Try to play with the Socket “-t” option. Make it -t 64 or maybe -t 128 see
if it helps

As for why the server terminates. QNX is very “sensitive” in terms of
illiage memory
access. In you case, it usually is not “terminated by OS”, but what we
called “crashed”.

You want to debug you code see WHY OS teminate it, you also want to make
sure
you are checking all the system call return value. (common mistack is
malloc() but
never bother check if the return is non-zero). You can use “dumper” to catch
the
“core dump” of you program when it is terminated by OS, and look into there
see
why the OS want to terminate it.

-xtang

Serg <skozak@eleks.lviv.ua> wrote in message
news:as8c5m$fc5$1@inn.qnx.com
Hello

I have a program ( quite a little one ) that was written using VC++ and then
ported to QNX.
The program is TCP/IP server which should have 50~100 client & server socket
connections and 100~200 threads to serve them. Client connection are used to
update data from some devices and these updates must be done as soon as
possible (it should take less than 50 ms for each update). Server
connections just listen for some ports and are used to pass updated data to
client or vice versa (clients ask QNX-server to write data to device). The
problem is it works too slow, even slower than on Windows 2000 !! The main
idea of porting the application to QNX was to increase update rate. But it’s
not the only problem: when there is a lot of threads the program sometimes
just terminates. The more threads the quicker this happens… Very strange
considering that there was no behaviour like this on NT. And it doesn’t
happens because main thread has terminated or something, it’s closed by OS.
Does anyone has any idea why all this may happen ?? I’m new in QNX
programming and I’m really stuck with this.

Thanks.

“Serg” <skozak@eleks.lviv.ua> wrote in message news:as8c5m$fc5$1@inn.qnx.com
Hello

I have a program ( quite a little one ) that was written using VC++ and then ported to QNX.
The program is TCP/IP server which should have 50~100 client & server socket connections and 100~200 threads to serve them.

Threads? You really mean threads not process? QNX4 doesn’t really support threads.

Client connection are used to update data from some devices and these updates must be done as soon as possible (it should take less than 50 ms for each update). Server connections just listen for some ports and are used to pass updated data to client or vice versa (clients ask QNX-server to write data to device). The problem is it works too slow, even slower than on Windows 2000 !! The main idea of porting the application to QNX was to increase update rate. But it’s not the only problem: when there is a lot of threads the program sometimes just terminates. The more threads the quicker this happens… Very strange considering that there was no behaviour like this on NT. And it doesn’t happens because main thread has terminated or something, it’s closed by OS.
Does anyone has any idea why all this may happen ?? I’m new in QNX programming and I’m really stuck with this.

Thanks.

yeah, threads. They’re created by pthread_create() call… Actually I’m using QNX6, is there some major differences between QNX4 & QNX6 with working with threads ?? What do you mean by “QNX4 doesn’t really support threads” ?

“Mario Charest” postmaster@127.0.0.1 wrote in message news:as92jq$8ns$1@inn.qnx.com

“Serg” <skozak@eleks.lviv.ua> wrote in message news:as8c5m$fc5$1@inn.qnx.com
Hello

I have a program ( quite a little one ) that was written using VC++ and then ported to QNX.
The program is TCP/IP server which should have 50~100 client & server socket connections and 100~200 threads to serve them.

Threads? You really mean threads not process? QNX4 doesn’t really support threads.

Client connection are used to update data from some devices and these updates must be done as soon as possible (it should take less than 50 ms for each update). Server connections just listen for some ports and are used to pass updated data to client or vice versa (clients ask QNX-server to write data to device). The problem is it works too slow, even slower than on Windows 2000 !! The main idea of porting the application to QNX was to increase update rate. But it’s not the only problem: when there is a lot of threads the program sometimes just terminates. The more threads the quicker this happens… Very strange considering that there was no behaviour like this on NT. And it doesn’t happens because main thread has terminated or something, it’s closed by OS.
Does anyone has any idea why all this may happen ?? I’m new in QNX programming and I’m really stuck with this.

Thanks.

Please give some more explanations about “-t” options: I don’t really
understand what you’re talking about.

About abnormal program termination: I really don’t think it’s caused by
memory leaks or something like that.
In fact I do not call any malloc() in the program cause there is no need for
it. I have one big buffer to read from & to write to.
This buffer is used by many threads and is protected by mutexes…that’s all
the program actually… The only APIs I’m using are for
managing threads, synchronization and work with sockets.
The program terminates very “clearly”: no messages or errors… What kind
of errors can cause this ?? Illegal memory access cause
“Core dumped” error, right ?

Thanks for your comments.



“Xiaodan Tang” <xtang@qnx.com> wrote in message
news:as8gma$rb4$1@nntp.qnx.com

Try to play with the Socket “-t” option. Make it -t 64 or maybe -t 128 see
if it helps

As for why the server terminates. QNX is very “sensitive” in terms of
illiage memory
access. In you case, it usually is not “terminated by OS”, but what we
called “crashed”.

You want to debug you code see WHY OS teminate it, you also want to make
sure
you are checking all the system call return value. (common mistack is
malloc() but
never bother check if the return is non-zero). You can use “dumper” to
catch
the
“core dump” of you program when it is terminated by OS, and look into
there
see
why the OS want to terminate it.

-xtang

Serg <> skozak@eleks.lviv.ua> > wrote in message
news:as8c5m$fc5$> 1@inn.qnx.com> …
Hello

I have a program ( quite a little one ) that was written using VC++ and
then
ported to QNX.
The program is TCP/IP server which should have 50~100 client & server
socket
connections and 100~200 threads to serve them. Client connection are used
to
update data from some devices and these updates must be done as soon as
possible (it should take less than 50 ms for each update). Server
connections just listen for some ports and are used to pass updated data
to
client or vice versa (clients ask QNX-server to write data to device). The
problem is it works too slow, even slower than on Windows 2000 !! The main
idea of porting the application to QNX was to increase update rate. But
it’s
not the only problem: when there is a lot of threads the program sometimes
just terminates. The more threads the quicker this happens… Very
strange
considering that there was no behaviour like this on NT. And it doesn’t
happens because main thread has terminated or something, it’s closed by
OS.
Does anyone has any idea why all this may happen ?? I’m new in QNX
programming and I’m really stuck with this.

Thanks.

“Serg” <skozak@eleks.lviv.ua> wrote in message
news:asib8l$hri$1@inn.qnx.com
yeah, threads. They’re created by pthread_create() call… Actually I’m
using QNX6, is there some major differences between QNX4 & QNX6 with working
with threads ?? What do you mean by “QNX4 doesn’t really support threads” ?

It means exactly what it means: QNX4 Does Not Support Threads. Only
processes.

// wbr

But QNX6 does support threads, doesn’t it ?
So there is no pthread_* calls in QNX4 ?

“Ian Zagorskih” <ianzag@megasignal.com> wrote in message
news:asicja$j0d$1@inn.qnx.com

“Serg” <> skozak@eleks.lviv.ua> > wrote in message
news:asib8l$hri$> 1@inn.qnx.com> …
yeah, threads. They’re created by pthread_create() call… Actually I’m
using QNX6, is there some major differences between QNX4 & QNX6 with
working
with threads ?? What do you mean by “QNX4 doesn’t really support threads”
?

It means exactly what it means: QNX4 Does Not Support Threads. Only
processes.

// wbr

You are posting in “qdn.public.qnx4.devtools”, so I suppose you are using
QNX4. But from your other thread (and the message below), you are using
QNX6. That’s where people get confused. You should re-post you question to
qdn.public.devtools.

For you problem, you probably want to check out the Util Reference Manual
for npm-tcpip.so and dumper.

-xtang

Serg <skozak@eleks.lviv.ua> wrote in message
news:asid07$ji7$1@inn.qnx.com

Please give some more explanations about “-t” options: I don’t really
understand what you’re talking about.

About abnormal program termination: I really don’t think it’s caused by
memory leaks or something like that.
In fact I do not call any malloc() in the program cause there is no need
for
it. I have one big buffer to read from & to write to.
This buffer is used by many threads and is protected by mutexes…that’s
all
the program actually… The only APIs I’m using are for
managing threads, synchronization and work with sockets.
The program terminates very “clearly”: no messages or errors… What kind
of errors can cause this ?? Illegal memory access cause
“Core dumped” error, right ?

Thanks for your comments.



“Xiaodan Tang” <> xtang@qnx.com> > wrote in message
news:as8gma$rb4$> 1@nntp.qnx.com> …
Try to play with the Socket “-t” option. Make it -t 64 or maybe -t 128
see
if it helps

As for why the server terminates. QNX is very “sensitive” in terms of
illiage memory
access. In you case, it usually is not “terminated by OS”, but what we
called “crashed”.

You want to debug you code see WHY OS teminate it, you also want to make
sure
you are checking all the system call return value. (common mistack is
malloc() but
never bother check if the return is non-zero). You can use “dumper” to
catch
the
“core dump” of you program when it is terminated by OS, and look into
there
see
why the OS want to terminate it.

-xtang

Serg <> skozak@eleks.lviv.ua> > wrote in message
news:as8c5m$fc5$> 1@inn.qnx.com> …
Hello

I have a program ( quite a little one ) that was written using VC++ and
then
ported to QNX.
The program is TCP/IP server which should have 50~100 client & server
socket
connections and 100~200 threads to serve them. Client connection are
used
to
update data from some devices and these updates must be done as soon as
possible (it should take less than 50 ms for each update). Server
connections just listen for some ports and are used to pass updated data
to
client or vice versa (clients ask QNX-server to write data to device).
The
problem is it works too slow, even slower than on Windows 2000 !! The
main
idea of porting the application to QNX was to increase update rate. But
it’s
not the only problem: when there is a lot of threads the program
sometimes
just terminates. The more threads the quicker this happens… Very
strange
considering that there was no behaviour like this on NT. And it doesn’t
happens because main thread has terminated or something, it’s closed by
OS.
Does anyone has any idea why all this may happen ?? I’m new in QNX
programming and I’m really stuck with this.

Thanks.

\

Sorry, I didn’t realize that there were so big differences between QNX4 &
QNX6 in described topics.


“Xiaodan Tang” <xtang@qnx.com> wrote in message
news:asie0d$rg4$1@nntp.qnx.com

You are posting in “qdn.public.qnx4.devtools”, so I suppose you are using
QNX4. But from your other thread (and the message below), you are using
QNX6. That’s where people get confused. You should re-post you question to
qdn.public.devtools.

For you problem, you probably want to check out the Util Reference Manual
for npm-tcpip.so and dumper.

-xtang

Serg <> skozak@eleks.lviv.ua> > wrote in message
news:asid07$ji7$> 1@inn.qnx.com> …
Please give some more explanations about “-t” options: I don’t really
understand what you’re talking about.

About abnormal program termination: I really don’t think it’s caused by
memory leaks or something like that.
In fact I do not call any malloc() in the program cause there is no need
for
it. I have one big buffer to read from & to write to.
This buffer is used by many threads and is protected by mutexes…that’s
all
the program actually… The only APIs I’m using are for
managing threads, synchronization and work with sockets.
The program terminates very “clearly”: no messages or errors… What
kind
of errors can cause this ?? Illegal memory access cause
“Core dumped” error, right ?

Thanks for your comments.



“Xiaodan Tang” <> xtang@qnx.com> > wrote in message
news:as8gma$rb4$> 1@nntp.qnx.com> …
Try to play with the Socket “-t” option. Make it -t 64 or maybe -t 128
see
if it helps

As for why the server terminates. QNX is very “sensitive” in terms of
illiage memory
access. In you case, it usually is not “terminated by OS”, but what we
called “crashed”.

You want to debug you code see WHY OS teminate it, you also want to
make
sure
you are checking all the system call return value. (common mistack is
malloc() but
never bother check if the return is non-zero). You can use “dumper” to
catch
the
“core dump” of you program when it is terminated by OS, and look into
there
see
why the OS want to terminate it.

-xtang

Serg <> skozak@eleks.lviv.ua> > wrote in message
news:as8c5m$fc5$> 1@inn.qnx.com> …
Hello

I have a program ( quite a little one ) that was written using VC++
and
then
ported to QNX.
The program is TCP/IP server which should have 50~100 client & server
socket
connections and 100~200 threads to serve them. Client connection are
used
to
update data from some devices and these updates must be done as soon
as
possible (it should take less than 50 ms for each update). Server
connections just listen for some ports and are used to pass updated
data
to
client or vice versa (clients ask QNX-server to write data to device).
The
problem is it works too slow, even slower than on Windows 2000 !! The
main
idea of porting the application to QNX was to increase update rate.
But
it’s
not the only problem: when there is a lot of threads the program
sometimes
just terminates. The more threads the quicker this happens… Very
strange
considering that there was no behaviour like this on NT. And it
doesn’t
happens because main thread has terminated or something, it’s closed
by
OS.
Does anyone has any idea why all this may happen ?? I’m new in QNX
programming and I’m really stuck with this.

Thanks.



\

“Serg” <skozak@eleks.lviv.ua> wrote in message
news:asidaq$jk1$1@inn.qnx.com

But QNX6 does support threads, doesn’t it ?

Yes, it does support full (afaik) pthread_* calls set.

So there is no pthread_* calls in QNX4 ?

No, there are no native pthread_* calls in QNX4.

QNX4 and QNX6 are two very different operating systems. So that’s not
wondering that they are incompatible with each other.

Theoretically, there are available a library for QNX4 using which you can
get some pthread_* calls. Use it or not is your choise but afaiu it’s more
then unstable and extraneous for QNX4 code :slight_smile:

“Ian Zagorskih” <> ianzag@megasignal.com> > wrote in message
news:asicja$j0d$> 1@inn.qnx.com> …

“Serg” <> skozak@eleks.lviv.ua> > wrote in message
news:asib8l$hri$> 1@inn.qnx.com> …
yeah, threads. They’re created by pthread_create() call… Actually I’m
using QNX6, is there some major differences between QNX4 & QNX6 with
working
with threads ?? What do you mean by “QNX4 doesn’t really support
threads”
?

// wbr

QNX4 did kind of support threads. But it was a real hack.

What plagued me was that errno was not thread safe. If one thread did an IO
and returned an error, it was possible (likely in my case) that another
thread would clobber errno before you had a change to examine it.

“Ian Zagorskih” <ianzag@megasignal.com> wrote in message
news:asicja$j0d$1@inn.qnx.com

“Serg” <> skozak@eleks.lviv.ua> > wrote in message
news:asib8l$hri$> 1@inn.qnx.com> …
yeah, threads. They’re created by pthread_create() call… Actually I’m
using QNX6, is there some major differences between QNX4 & QNX6 with
working
with threads ?? What do you mean by “QNX4 doesn’t really support threads”
?

It means exactly what it means: QNX4 Does Not Support Threads. Only
processes.

// wbr

As for why the server terminates. QNX is very “sensitive” in terms of
illiage memory
access. In you case, it usually is not “terminated by OS”, but what we
called “crashed”.
You want to debug you code see WHY OS teminate it, you also want to make
sure you are checking all the system call return value. (common mistack is
malloc() but
never bother check if the return is non-zero). You can use “dumper” to
catch the
“core dump” of you program when it is terminated by OS, and look into
there see
why the OS want to terminate it.

Thank you very much for this. There was some illiage memory. I was trying to
reconnect to host after some time if the previous connection was refused and
accidentally called socket() a lot of times. After fixing this all seem to
be in order.



Try to play with the Socket “-t” option. Make it -t 64 or maybe -t 128 see
if it helps

For you problem, you probably want to check out the Util Reference Manual
for npm-tcpip.so and dumper.

The other problem is I cann’t create more than ~40 socket connections. A
little less works fine but the next ones block tcp/ip requests. This
probably is caused by the tcp/ip stack. I did look to Util Reference Manual
but I couldn’t do anything with it. I wrote something like this:
io-net -ptcpip threads=128
and after this command all socket commands failed.
Please help to do something with it.
Thanks in advance.


-xtang

Serg <> skozak@eleks.lviv.ua> > wrote in message
news:as8c5m$fc5$> 1@inn.qnx.com> …
Hello

I have a program ( quite a little one ) that was written using VC++ and
then
ported to QNX.
The program is TCP/IP server which should have 50~100 client & server
socket
connections and 100~200 threads to serve them. Client connection are used
to
update data from some devices and these updates must be done as soon as
possible (it should take less than 50 ms for each update). Server
connections just listen for some ports and are used to pass updated data
to
client or vice versa (clients ask QNX-server to write data to device). The
problem is it works too slow, even slower than on Windows 2000 !! The main
idea of porting the application to QNX was to increase update rate. But
it’s
not the only problem: when there is a lot of threads the program sometimes
just terminates. The more threads the quicker this happens… Very
strange
considering that there was no behaviour like this on NT. And it doesn’t
happens because main thread has terminated or something, it’s closed by
OS.
Does anyone has any idea why all this may happen ?? I’m new in QNX
programming and I’m really stuck with this.

Thanks.