tfork()

I am looking at using tfork() in a QNX4 application. My created child task
(thread) will only be using the following library functions:

malloc()
Receive()
Reply()
memset()
memcpy()

Does any know if I would be safe in using tfork(). I don’t know if any of
these functions are thread safe in QNX4.

Tom Stave <thstave@home.com> wrote:

I am looking at using tfork() in a QNX4 application. My created child task
(thread) will only be using the following library functions:

malloc()

malloc is risky. The problem is that both “threads” would share the
same data segment, and so the same data chain. Can you pre-allocate
some memory the thread will use, and let it manage that memory itself?
Maybe give it a pool of buffers, or something like that?

If using malloc, are you also using free()? It has similar issues.

Receive()
Reply()
memset()
memcpy()

The others are fine.

(malloc may be labelled as “thread safe” – but that implies _beginthread()
rather than tfork(), as that enables some library thread-safing stuff. Not
complete, but better.)

-David

QNX Training Services
dagibbs@qnx.com