Starting threads and processes in C++

Hi!

In the Watcom C library there are functions such as _beginthread()
and _endthread() to start and end threads and fork() for processes.

My question is: Are there any equivalent functions for C++, or do
I also use the C library commands to set up threads and processes in
C++.

Arve

Use the regular C library commands. If you feel more comfortable with thread
classes, you can create a thread class that encapsulates the C library
calls.

Daryl Low

“Arve Slenes” <slenesa@oslo.geco-prakla.slb.com> wrote in message
news:3B00DFA3.3A36D12D@oslo.geco-prakla.slb.com

Hi!

In the Watcom C library there are functions such as _beginthread()
and _endthread() to start and end threads and fork() for processes.

My question is: Are there any equivalent functions for C++, or do
I also use the C library commands to set up threads and processes in
C++.

Arve

Arve Slenes <slenesa@oslo.geco-prakla.slb.com> wrote:

Hi!

In the Watcom C library there are functions such as _beginthread()
and _endthread() to start and end threads and fork() for processes.

My question is: Are there any equivalent functions for C++, or do
I also use the C library commands to set up threads and processes in
C++.

Be careful. Be very very careful. The C library is mostly thread
unsafe, the C++ library is also iffy. If you absolutely MUST use
threads in a QNX 4 C++ environment, I would strongly suggest also
passing the -bm flag to wpp386 – this can be done with cc by
giving it “-WC,-bm”.


(BTW, this newsgroup is intended for QNX RTP discussion, that is, for
QNX6 – Watcom is not the compiler for QNX6. You might want
qdn.public.qnx4.os for further questions.)

-David

QNX Training Services
dagibbs@qnx.com

Now then. If I do use QNX RTP / QNX.v6
(I got to know this morning that we’re going to use QNX.v6).

How would that work with threads in C++?
Are there good thread support for C++ in QNX.v6?
Any C++ related problems I should know about?

Thanks!
-Arve

David Gibbs wrote:

Arve Slenes <> slenesa@oslo.geco-prakla.slb.com> > wrote:
Hi!

In the Watcom C library there are functions such as _beginthread()
and _endthread() to start and end threads and fork() for processes.

My question is: Are there any equivalent functions for C++, or do
I also use the C library commands to set up threads and processes in
C++.

Be careful. Be very very careful. The C library is mostly thread
unsafe, the C++ library is also iffy. If you absolutely MUST use
threads in a QNX 4 C++ environment, I would strongly suggest also
passing the -bm flag to wpp386 – this can be done with cc by
giving it “-WC,-bm”.

(BTW, this newsgroup is intended for QNX RTP discussion, that is, for
QNX6 – Watcom is not the compiler for QNX6. You might want
qdn.public.qnx4.os for further questions.)

-David

QNX Training Services
dagibbs@qnx.com

C++ is well supported on QNX6. It uses the GNU compiler.
About the libraries, I don’t know for sure, but from my own experience they
seem pretty thread stable, e.g., I output to cout from two threads and they
were no problems.
I do heavy C++ development and didn’t run into problems yet.
Markus

“Arve Slenes” <slenesa@oslo.geco-prakla.slb.com> wrote in message
news:3B023983.4D0008B6@oslo.geco-prakla.slb.com

Now then. If I do use QNX RTP / QNX.v6
(I got to know this morning that we’re going to use QNX.v6).

How would that work with threads in C++?
Are there good thread support for C++ in QNX.v6?
Any C++ related problems I should know about?

Thanks!
-Arve

David Gibbs wrote:

Arve Slenes <> slenesa@oslo.geco-prakla.slb.com> > wrote:
Hi!

In the Watcom C library there are functions such as _beginthread()
and _endthread() to start and end threads and fork() for processes.

My question is: Are there any equivalent functions for C++, or do
I also use the C library commands to set up threads and processes in
C++.

Be careful. Be very very careful. The C library is mostly thread
unsafe, the C++ library is also iffy. If you absolutely MUST use
threads in a QNX 4 C++ environment, I would strongly suggest also
passing the -bm flag to wpp386 – this can be done with cc by
giving it “-WC,-bm”.

(BTW, this newsgroup is intended for QNX RTP discussion, that is, for
QNX6 – Watcom is not the compiler for QNX6. You might want
qdn.public.qnx4.os for further questions.)

-David

QNX Training Services
dagibbs@qnx.com

Now then. If I do use QNX RTP / QNX.v6
(I got to know this morning that we’re going to use QNX.v6).

Whew ! You must be relieved.

How would that work with threads in C++?

Fine.

Are there good thread support for C++ in QNX.v6?

Works great for me.

Any C++ related problems I should know about?

No, in fact, in general you will have a much easier time with threads if
your code is truly object oriented, since (if your code is truly object
oriented) you will have no global variables, and therefore
synchronization problems will not be an issue (in practice there will
most likely be some sort of shared resource but this will be minimal and
well defined, as compared to procedural programming).

btw: note that I am assuming that when you say “C++” what you really
mean is OOP using C++ (as opposed to procedural programming using C++).

Now then. If I do use QNX RTP / QNX.v6
(I got to know this morning that we’re going to use QNX.v6).

How would that work with threads in C++?
Are there good thread support for C++ in QNX.v6?
Any C++ related problems I should know about?

Thanks!
-Arve

Anyone out there using JThreads from OOC under QNX 6?

I’ve used it under Linux/Solaris/Windows and it provides a nice abstraction
using a Java like thread model. You can download the source from
http://www.ooc.com/jtc/. It’s based on pthreads for UN*X like systems and I
think I even saw mention of QNX/Neutrino in the configuration options last
time I rebuilt (could be wrong).

Mix this with a good “smart pointer” class (ref counting a la Scott Meyers
More Effective C++) and working with threads in C++ becomes much less
painful.

Cheers,

Todd

YES!
OOP using UML doing the C++ design that is in this case.

Arve

Rennie Allen wrote:

btw: note that I am assuming that when you say “C++” what you really
mean is OOP using C++ (as opposed to procedural programming using C++).