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.
3. Multi-Threaded Programming<br />
with the programmed system calls. The correct result may depend on<br />
time, and different actions could be taken depending on time, but there<br />
is no guarantee concerning the time of execution.<br />
• Specifically, priorities are suggestions for the scheduling (and thereby the<br />
timing) but the correctness may not depend on priorities. Furthermore,<br />
waiting a specified time (sleep) or until a specified time (sleepUntil) only<br />
means that execution is suspended for at least that long. That permits<br />
the scheduler to have other threads running during the specified amount<br />
of time, but the software alone does not specify any upper limit of the<br />
real-time delay.<br />
These are basically the preconditions for the Java platform. It agrees well<br />
with concurrency for Internet applications; the network exhibits unpredictable<br />
timing anyway. It also agrees with the properties of the most well-known<br />
operating systems such as Unix (Solaris, Linux, etc.) and Windows-NT. With<br />
no further assumptions, our concurrent system is not a real-time system. (By<br />
simulating the environment we can, however, simulate a real-time system and<br />
carry out almost all of the software test and debugging.)<br />
Hence, multi-threaded programming (i.e., concurrent programming based<br />
on threads) should therefore not be confused with real-time programming<br />
which we will cope with in later chapters, just a few further comments here:<br />
In order to obtain correctness from a real-time point of view, a concurrent<br />
program has to be run on a real-time platform. Such a platform must fulfil<br />
additional requirements concerning CPU-speed, available memory, IO and<br />
interrupt handling, scheduling algorithms, and the input to the scheduler from<br />
the application software. Even on a non-real-time platform we may obtain a<br />
system behaviour that appears to be real-time. A common approach, for<br />
instance when using PCs in industrial automation, is to only let one or a<br />
few well-known programs/daemons/ services run, to have some activities run<br />
in some kind of kernel or driver mode, to tailor the application software for<br />
improved handling of sporadic delays (for instance by temporarily adjusting<br />
parameters and decrease performance), and by using a powerful computer.<br />
Still, since the system is not guaranteed to produce a quite correct result at<br />
the right time, it is not real time. But from an application point of view, the<br />
system behaviour can be good enough. Therefore, in a practical industrial<br />
context the borderline between real-time and concurrent programming is not<br />
that clear.<br />
3.1 Threads<br />
For now we assume that our concurrent activities can run independently of<br />
each other, with no need for synchronization and mutual exclusive methods.<br />
42 2012-08-29 16:05