NonStop Server for Java 6.0 Programmer's Reference
How to Call TNS Floating-Point Functions from JNI Code
This topic describes how to call a TNS floating-point function from an IEEE floating-point function.
When using TNS floating-point compiled functions in native code linked into the java executable:
• Do not call the Common Runtime Environment (CRE) functions with TNS floating-point values
because CRE functions are expecting IEEE floating-point values.
• Do not pass floating-point values (float and double) across mixed float compilation units.
When passing or returning floating-point values between IEEE floating-point compiled functions
and TNS floating-point compiled functions, pass or return.
◦ A float as one of the 32-bit structures defined in $SYSTEM.SYSTEM.KFPCONVH
(NSK_float_ieee32 or NSK_float_tns32)
◦ A double as one of the 64-bit structures defined in $SYSTEM.SYSTEM.KFPCONVH
(NSK_float_ieee64 or NSK_float_tns64)
• You can call a native function that accepts or returns a TNS float or double value if you
create an intermediate function that sits between the IEEE floating-point compiled JNI method
that the JVM calls and the native function that accepts or returns a TNS float or double .
Either the JNI method or the intermediate method can be responsible for calling one of the
NSK_float_* procedures to convert between IEEE and TNS floating-point formats.
The intermediate function:
◦ Is compiled with TNS floating point.
◦ Accepts float and double arguments as one of the special structures defined in the
$SYSTEM.SYSTEM.KFPCONVH file.
◦ Calls the TNS compiled native function passing TNS float or double arguments.
◦ Converts any float or double return value to an IEEE floating-point value of the JNI
caller expects the value.
◦ Returns the float or double in one of the special structures defined in the
$SYSTEM.SYSTEM.KFPCONVH file.
For an example, see the javahjni “Demonstration Programs” (page 41).
Multithreaded Programming
The Java virtual machine for the NonStop Server for Java 6.0 is multithreaded. It uses Standard
POSIX Threads, which conforms to IEEE POSIX Standard 1003.lc. Threads are scheduled for
execution by the Standard POSIX Threads library, not by the operating system. All threads created
within a process share the same process address space in the same CPU. With Standard POSIX
Threads on NonStop systems, one thread can never be preempted by another thread if the
–XX:ThreadTimeSlice option is not used.
The topics in this discussion are:
• “Thread Scheduling” (page 47)
• “Threading Considerations for Java Code” (page 49)
• “Threading Considerations for Native Code” (page 50)
Thread Scheduling
The Java runtime supports a simple, deterministic, scheduling algorithm known as fixed-priority
scheduling. By default, the Java runtime does not time-slice. You can enable time slicing by using
the –XX:ThreadTimeSlice option.
Multithreaded Programming 47










