06.08.2013 Views

JAVA-BASED REAL-TIME PROGRAMMING

JAVA-BASED REAL-TIME PROGRAMMING

JAVA-BASED REAL-TIME PROGRAMMING

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.9. Software issues<br />

In this chapter we have reviewed the properties of software execution, as<br />

expressed in the source code. The issues we are about to study are about software<br />

development, assuming that the underlying (virtual) machine machine<br />

(and system software) is correct. Assuming also that the compiler is correct<br />

(producing binary code, preferably efficient, that behaves as expressed in<br />

the source code), we might believe that we could do the programming in any<br />

(convenient) language. However, if a program (for instance during testing)<br />

works correctly, and is correct from the concurrency point of view, we cannot<br />

know that the program works correctly in another case, even if it was tested<br />

with all combinations of input data. The reason is that most languages do<br />

not prevent programs with undefined behavior, which may result in damaged<br />

data within the same object or at any other location within the program, or<br />

even outside the program if the OS does not provide memory protection. Undefined<br />

behavior can stem from use of uninitialized data, dangling pointers,<br />

unchecked typecasts, etc. Therefore, in order to be able to build systems that<br />

scale up for complex applications, we should use a language that only permits<br />

well-defined programs. We call such a language safe.<br />

Definition: A programming language is safe if and only if all possible<br />

executions of any program written in that language is expressed by the program<br />

itself.<br />

In particular, Java is safe (but native/unsafe code can be called), C#<br />

is not quite safe (safe except where the keyword unsafe is used, or when<br />

native code is called), Ada is unsafe, while C and C++ are clearly unsafe.<br />

Every language must permit unsafe code to be called, otherwise device drivers<br />

could not be used. You may consider it as a deficiency that neither viruses<br />

nor device drivers can be written in Java; some implementation has to be<br />

done in some other language. One could also consider it as an advantage;<br />

hardware access (which will not be portable anyway) has to be written well<br />

separated from the rest of the application. Those (usually small) pieces of<br />

software also have to be more thoroughly debugged since a programming error<br />

could crash the entire system without exception handling of system shutdown<br />

working, opposed to safe programs which terminates in a controlled way with<br />

supervisory functions and recovery systems still running. We use a Javabased<br />

approach to embedded systems programming since we need to trust<br />

their behavior.<br />

2.9 Software issues<br />

Based on the properties of software execution in general, and on the, for our<br />

purposes, quite good design choices made in the Java language, we are now<br />

ready to tackle the issue of concurrent and real-time programming. To sum<br />

up, we should be able to develop software such that the following is obtained:<br />

• Correctness from a concurrent point of view; all allowed interleavings<br />

39

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!