DCE Application Programming Guide

Application Programming With NonStop DCE
Threads
HP NonStop DCE Application Programming Guide429551-003
3-8
Spawning a New Process
Spawning a New Process
Using any version of the fork functions in a multithreaded environment can cause
problems. Section 8.13 of the OSF DCE Application Development Guide discusses the
various problems associated with using those functions.
Applications can use a fork function safely under these conditions:
A parent process can safely spawn a child process if the parent process invokes
the fork() or tdm_fork() function before calling any function in the DCE API.
This method is often used to create a demon process that can run in the
background.
A parent process that has already called a function in the DCE API can also use a
fork function to create a child process if the child process calls the exec(),
tdm_execve(), or tdm_execep() function immediately upon its creation. (For
more information about the use of exec functions, see Section 8.13 of the OSF
DCE Application Development Guide.)
Isolating Faults
Because all threads created by a process share the process address space, there is
no protection between threads. An application thread can corrupt data, causing other
threads or the entire process to fail.
NonStop DCE Jacket Routines
A jacket routine invokes a nonblocking (nowait) version of a Guardian procedure call
and suspends the thread until the thread’s operation is complete. NonStop DCE
provides jacket routines for SERVERCLASS_SEND_, SERVERCLASS_SEND_INFO_,
SERVERCLASS_DIALOG_BEGIN_, SERVERCLASS_DIALOG_SEND_,
SERVERCLASS_DIALOG_END_, and SERVERCLASS_DIALOG_ABORT_ calls and for
TMF transaction demarcation.
SERVERCLASS_SEND_ Jacket
The DCE_SERVERCLASS_SEND_() function in the threads library is used for sending a
message to and receiving a reply from a server process in a Pathway server class.
This jacket routine invokes a nowait version of the Guardian SERVERCLASS_SEND_
procedure. The thread that makes the call is suspended until the send operation has
finished. Another jacket, the DCE_SERVERCLASS_SEND_INFO_() function, is also
provided. It returns information about the last DCE_SERVERCLASS_SEND_() call that
was attempted or completed by the current thread. The
DCE_SERVERCLASS_SEND_INFO_() function ensures that the thread gets the
information for the last message sent by the thread rather than by the process. See
SERVERCLASS_SEND_INFO_ Jacket.