JAVA-BASED REAL-TIME PROGRAMMING
JAVA-BASED REAL-TIME PROGRAMMING
JAVA-BASED REAL-TIME PROGRAMMING
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
2.7 Multi-process programming<br />
2.7. Multi-process programming<br />
Programming languages include constructs for expressing the execution of one<br />
program, while interaction between programs are handled via library calls.<br />
Exercises in basic programming courses are solved by writing one program,<br />
possibly in several files that are compiled separately, but linked as one executable<br />
unit which is executed within one OS process. Possibly, event handlers<br />
(in terms of event listeners or callback routines) or multiple threads are used,<br />
but it is one program and one process sharing a common memory space. Note<br />
that even if we let different OS processes share memory (via system calls such<br />
as mmap in UNIX), we have no language support for signaling and mutual<br />
exclusion; that too has to be handled via system calls.<br />
Using multiple threads (multi-threaded programming) can, in principle, as<br />
mentioned, be used to create any concurrency. Also for utilization of multiple<br />
CPUs (with shared memory), threads are enough. So, in real-world systems,<br />
what are the reasons for using multiple processes instead of just multiple<br />
threads? In short, reasons for dividing a software application into multiple<br />
OS processes include the following:<br />
1. Different parts of the applications need to run on different computers<br />
which are distributed (not sharing memory).<br />
2. Different parts of the application need different permissions and access<br />
rights, or different sets of system resources.<br />
3. In the Java case, different virtual machine properties (such as GC properties)<br />
can be desirable for different parts of the system, depending on<br />
timing demands etc.<br />
4. If the application consists of (new) Java parts and other (typically old,<br />
so called legacy) parts written in other languages like C, these parts can<br />
be interfaces and linked together using the Java Native Interface (JNI).<br />
However, if the virtual machine and the legacy code requires specific but<br />
different native threading libraries, this may not be possible (resulting<br />
in linkage errors). This is solved by using multiple processes.<br />
5. Licensing terms for different parts of the application can forbid execution<br />
as one process. For instance, GNU-type of free software (GPL) may not<br />
be linked with proprietary software.<br />
6. A large application including code written in an unsafe language (such<br />
as C/C++) will be more reliable if it is divided into several executable<br />
units, each with its own memory space and with memory accesses checked<br />
by the MMU (memory management unit) hardware. Instead of a ’bluescreen’<br />
due to an illegal access, just one part of the application may stop.<br />
The use of protected memory is a main reason why large systems have<br />
37