Threading considerations for native code
The JNI or C/C++ code in a Java application that uses the Pthread API must be ported to use the
_PUT_MODEL_as described in the Open System Services Programmer's Guide.The PUT library
WPUTDLLmust be linked to the application.
If a user native library linked into Java creates a thread, non thread-aware operations executed in the user library might impact the operation of the Java virtual machine. If the user library creates multiple user threads, the program needs to be more careful to ensure that the operations performed in the user threads are thread-safe on the NonStop system. All threaded code preferably written in Java rather than native code.
You need to consider the following issues when using threads in native code linked to a Java program on a NonStop system:
NSJ uses the POSIX User Thread Library from the standard location.
Your code must include the POSIX User Thread header files in the standard location. You must use the header files from the standard location
/usr/include/.Creating a thread for a task does not make the task run faster.
The NonStop system does not have an implementation of native threads since threads run at a user level. Even on a multiprocessor NonStop system, all native threads (user threads) in a process are executed in the same processor as the process. If you create user threads whose only purpose is to run a certain task, the thread creation overhead makes the task run slower than the same task being performed without creating the thread.
The thread-scheduling algorithm is not preemptive.
A thread executes until it explicitly yields. For more information, see Thread scheduling.
- In a very long-running, CPU-intensive thread, having your native code occasionally invokes the
yield()method which allows timer and I/O completions to be detected. Invocation of timer callbacks and detection of I/O completions can be severely impacted by long-running threads. Provides standard POSIX thread API names and calling sequences which adhere to IEEE standard 1003.1, 2004. For more information, see Open System Services Programmer's Guide.
You must be careful when using thread-aware interfaces.
The Open System Services Programmer’s Guide lists thread-aware equivalents of NonStop system-specific interfaces. These interfaces have an explicit
put_prefix.For example, when using a thread-aware function, do not attempt to control the set of files that are enabled for completion or directly attempt to wait for a completion on a file registered with Pthreads (
FILE_COMPLETE_SET_,FILE_COMPLETE_,AWAITIO, orAWAITIOXprocedure).

