18 July 2014 A multi-threaded approach to using asynchronous C libraries with Java
Author Affiliations +
Abstract
It is very common to write device drivers and code that access low level operation system functions in C or C+ +. There are also many powerful C and C++ libraries available for a variety of tasks. Java is a programming language that is meant to be system independent and is arguably much simpler to code than C/C++. However, Java has minimal support for talking to native libraries, which results in interesting challenges when using C/C++ libraries with Java code. Part of the problem is that Java's standard mechanism for communicating with C libraries, Java Native Interface, requires a significant amount of effort to do fairly simple things, such as copy structure data from C to a class in Java. This is largely solved by using the Java Native Access Library, which provides a reasonable way of transferring data between C structures and Java classes and calling C functions from Java. A more serious issue is that there is no mechanism for a C/C++ library loaded by a Java program to call a Java function in the Java program, as this is a major issue with any library that uses callback functions. A solution to this problem was found using a moderate amount of C code and multiple threads in Java. The Keck Task Language API (KTL) is used as a primary means of inter-process communication at Keck and Lick Observatory. KTL is implemented in a series or C libraries and uses callback functions for asynchronous communication. It is a good demonstration of how to use a C library within a Java program.
© (2014) COPYRIGHT Society of Photo-Optical Instrumentation Engineers (SPIE). Downloading of the abstract is permitted for personal use only.
John Gates, William Deich, "A multi-threaded approach to using asynchronous C libraries with Java", Proc. SPIE 9152, Software and Cyberinfrastructure for Astronomy III, 91522Y (18 July 2014); doi: 10.1117/12.2055203; https://doi.org/10.1117/12.2055203
PROCEEDINGS
11 PAGES


SHARE
RELATED CONTENT


Back to Top