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. Fundamentals<br />
been possible to develop despite unsafe languages. Still, any program<br />
may contain fatal bugs, but a safe language such as Java ensures that<br />
at least the errors are kept local and exception handling works.<br />
7. Libraries, subsystems, or legacy software in general may not be thread<br />
safe. That is, variables (or attributes or fields) for storage of local data<br />
within a function (or method or procedure) may be declared static. That<br />
used to be a way to speed up programs and to save stack space, but the<br />
result is that the function can only be called by one thread at a time. By<br />
obtaining concurrency only via OS processes, we do not have to require<br />
the software to be thread safe since each process has its own memory<br />
allocated by the OS.<br />
Sometimes you may want to develop classes and active objects which can be<br />
run either as threads or as a processes, without changing the code. Such issues<br />
and the principles of how to design and implement multi-process applications<br />
are topics of Chapter 7.<br />
Note that from a concurrent design point of view, neglecting implementation<br />
issues such as if concurrency should be accomplished by threads or<br />
processes, we usually use the term process to refer to a (concurrently executing)<br />
activity. This is in line with non-technical vocabulary where a process<br />
refers to some ongoing activity that cannot be completed immediately. (Pay<br />
attention to how the word is used in the news, in economy, and in management<br />
principles.)<br />
2.8 Object interaction and encapsulation<br />
The interaction (information exchange) between objects may be synchronous<br />
or asynchronous. It can be built into the programming language, and/or it<br />
can be programmed. Synchronous communication can be implemented on top<br />
of asynchronous communication, or vice versa.<br />
Here, we consider synchronous communication as more fundamental. With<br />
the execution properties of Java this simply means a method invocation, which<br />
is based on ordinary function calls (works exactly as in C/C++ and most other<br />
languages). Thus, it is built into the language. This is the most computingefficient<br />
way to achieve object interaction in compiled languages.<br />
The asynchronous communication means passing some kind of message<br />
without requiring the sender/caller to wait until the receiver/callee replies;<br />
the caller performs its communication asynchronously with the callee. The<br />
messages are often referred to as events. But note, however, most of the<br />
event processing done for instance in Java’s AWT or Microsoft’s MFC actually<br />
constitutes synchronous communication because there are no buffers providing<br />
the asynchronous behaviour. It depends on the application demands if we want<br />
buffering or not. We will take a closer look at this issue in later chapters.<br />
38 2012-08-29 16:05