NonStop Server for Java (NSJ) Programmer's Guide (NSJ 2.0+)

can write any multithreaded code in Java.
When calling a C or C++ routine, function returns and parameters of type float or double are converted from
Compaq format to IEEE floating-point format and back. This might result in loss of precision because of differences
between Compaq format and IEEE floating-point format.
When naming library files, observe the following rules:
Do not use names that begin with "Tandem" or "tandem".
Do not use the same filename for more than one library file, even if the two library files are in different directories.
The remainder of this subsection explains:
Calling C or C++ Methods From Java
Calling Java Methods From C or C++
For more information about JNI, see the Sun Microsystems JNI document
(http://www.javasoft.com/products/jdk/1.2/docs/guide/jni/index.html).
Calling C or C++ Methods From Java
To call C or C++ methods from Java, follow these steps:
Compile the Java code.1.
Use javah to generate header files.2.
Compile the C or C++ code. C++ code must be compiled using the -Wversion2 compiler command-line option.3.
Create the library (.a) file.4.
Place the newly created library (.a) file in /usr/tandem/java/lib.5.
Relink the Java Virtual Machine (JVM) by using the /usr/tandem/install/Makefile. For more information
about the Makefile, see the /usr/tandem/install/README file.
6.
The remainder of this subsection:
Explains how to write thread-safe native methods
Explains how to use sockets
Gives a debugging tip
Writing Thread-Safe Native Methods
A thread that is sleeping or executing a blocked routine is blocked. NonStop
TM
Server for Java runs the highest-priority
thread that is not blocked. If more than one thread has the highest priority, all of those threads get some processor time.
Lower-priority threads are only guaranteed to run when higher-priority threads are blocked. Lower-priority threads might run
when higher-priority threads are not blocked, but this result is not guaranteed. The Java Run-Time can suspend any thread,
regardless of its priority, to run another thread at the same priority.
You are encouraged to write threaded code in Java rather than in native C or C++.
If you do write threaded native C or C++ methods, they must:
Use the same Pthread library and wrappers that the JVM uses; that is, the OSS Pthread library
(/usr/tandem/java/include/oss/dce).
Use Pthread wrappers for any functions that mandate thread-aware activity, such as socket I/O, file I/O, and pipes.
Because Pthreads are user-level threads, the operating system does not schedule each thread independently, and therefore,
operating system calls from a user thread can block the entire JVM rather than only the active thread. Pthread wrappers
prevent this problem. Each Pthread wrapper registers its call with the Pthread dispatcher, uses the appropriate NOWAIT
operation for the call, then suspends the thread. After the NOWAIT operation completes, the Pthread dispatcher resumes the
appropriate thread.
Compaq NonStop
TM
SQL/MP operations invoked by the type-2 JDBC
TM
driver for SQL/MP block the JVM until the
operation is completed (that is, these operations are not threaded).