JAVA-BASED REAL-TIME PROGRAMMING
JAVA-BASED REAL-TIME PROGRAMMING
JAVA-BASED REAL-TIME PROGRAMMING
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
2.6. Models of concurrent execution<br />
embedded systems, thread objects provide almost the same execution<br />
efficiency. The major reasons for omitting the coroutines in the Java<br />
language are: 1) The language can be kept simpler. 2) Most programmers<br />
do not know how to utilize coroutines anyway, particularly not in<br />
combination with threads. 3) Having the programmer to use threads<br />
instead means that the run-time system is free to let activities run in<br />
parallel if there are multiple CPUs available.<br />
• The threads are based on so called native methods, i.e., functions that<br />
are implemented external to the JVM. In the case of thread support,<br />
native methods may be implemented by the operating system. Thread<br />
creation, interaction, and scheduling are then handled by the system<br />
functions which are optimized for the actual hardware used (and run in<br />
parallel as mentioned in the previous item). Of course there is a lack of<br />
elegance compared to a system based on coroutines, having the scheduler<br />
implemented as in the language itself. However, for the majority of applications<br />
running on an operating system such as the Solaris operating<br />
system (the Sun UNIX which supports up to 64 processors), using the<br />
native threads boosts performance (without changing the source code).<br />
In conclusion, Java provides passive objects and active objects. A passive<br />
object is either an ordinary object, or it can be an object with no data exposed<br />
and all methods synchronized which then functions like a monitor. There<br />
are, however, no real monitors in the language; the programmer may expose<br />
data to concurrent access and some methods may be left unsynchronized.<br />
Active objects are those with the thread property, but we do not have (and<br />
we will not talk about) tasks since we do not have threads with implicit mutual<br />
exclusion. We will therefore only speak about classes, objects, synchronized<br />
methods, and threads. These are our building blocks for concurrent and realtime<br />
programming. There is, however, very little support for handling timing<br />
requirements, which we will return to in the final chapters.<br />
2.6.3 Processes and interrupts<br />
In the above treatment of programming language support for concurrency,<br />
we neglected two aspects, processes and interrupt service routines. In short, a<br />
process is the type of concurrent execution we have when we run some program<br />
under an operating system such as UNIX or Windows NT, and an interrupt<br />
service is the concurrent execution we have when a hardware interrupt starts<br />
a new thread of execution. These have to do with the interaction between the<br />
Java program and its environment in terms of hardware or other programs.<br />
Since this is quite dependent of the specific environment, it is probably a good<br />
idea not to provide any language support. Instead, we use classes that provide<br />
certain programming interfaces. Here, we will use the term interrupt to denote<br />
the execution carried out to service the actual hardware interrupt.<br />
35