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. Fundamentals<br />

Both a process and an interrupt contain threading and some kind of execution<br />

state, but a process is more powerful than a thread whereas an interrupt<br />

is less powerful. In more detail:<br />

• A process may contain one or several threads which we then say are<br />

internal to the process. The internal threads share a common address<br />

space in which they can share data and communicate without having to<br />

copy or transfer data via pipes or files. An object reference (or pointer<br />

in C/C++) can be used by several threads, but sharing objects between<br />

processes requires special techniques. The same applies to calls<br />

of member functions. All threads of one process have the same access<br />

rights concerning system calls, file access, etc. Different processes, on<br />

the other hand, may have different access rights.<br />

The concept of a process makes it possible to isolate execution and data<br />

references of one program. By controlling the MMU (Memory Management<br />

Unit) accordingly, an illegal data access (due to dereference of a<br />

dangling pointer in a C program for instance) can be trapped and handled<br />

by the operating system. To the UNIX user, there will be something<br />

like a “segmentation fault” message. In Windows 95/98, which<br />

lacks this support, one application programming error may crash other<br />

applications or even hang the operating system.<br />

• An interrupt starts a new execution thread, but it is subject to special<br />

restrictions. First, it must complete without blocking because it may not<br />

change execution state (switch context). Second, the interrupt may only<br />

start in a static function/method because this type of hardware call does<br />

not provide function arguments such as the implicit this pointer. Third,<br />

an interrupt may run within the context of another thread because the<br />

final restore of used registers and the requirement of “execution until<br />

completion” ensures that the context of the interrupted thread will be<br />

restored. The priorities of interrupts are managed by the hardware.<br />

Thus, whereas threads will be the most common way to accomplish concurrently<br />

executing software entities, an ISR is sometimes more appropriate or<br />

even necessary (device drivers), or there may be reasons for using (OS) processes<br />

instead of threads. Device drivers cannot be (purely) implemented in<br />

Java, and such machine-level programming is outside the scope of this book;<br />

it is well known how to do that and there are several hardware/OS-specific<br />

manuals/books on the topic. The issue of multithreading versus multiprocessing<br />

is more relevant, in particular for large complex systems, deserving a more<br />

detailed treatment.<br />

36 2012-08-29 16:05

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

Saved successfully!

Ooh no, something went wrong!