06.08.2013 Views

JAVA-BASED REAL-TIME PROGRAMMING

JAVA-BASED REAL-TIME PROGRAMMING

JAVA-BASED REAL-TIME PROGRAMMING

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 3<br />

Multi-Threaded Programming<br />

Goal: To know concurrent object-oriented programming using standard<br />

Java.<br />

With understanding of application demands and concepts presented in<br />

previous chapters, we will in this chapter look into the issue of handling concurrency<br />

within one program, utilizing the features of the Java-platform. Acquaintance<br />

with both (sequential programming in) Java and object oriented<br />

programming (OOP) is assumed. The following properties and restrictions<br />

should be clear to the reader:<br />

• One program means one executable unit in which different objects (possibly<br />

concurrently) can address data in a common memory space. The<br />

program is run either as one process using an Operating System (OS)<br />

or as an embedded application linked together with a so called real-time<br />

kernel (or RTOS).<br />

• As should be clear from the application examples, the software needs<br />

to respond to concurrently occurring external events. Sequential computing<br />

and handling of sequences of such events, expressed as ordinary<br />

sequential programs, then has to be executed concurrently.<br />

• By simply using the concept of thread objects, we assume that the underlying<br />

OS/kernel (which includes a scheduler) schedules the concurrent<br />

threads (normally many) for execution on the available CPUs (normally<br />

one). Hence, the system interleaves the code at run-time based on system<br />

calls which have been programmed according to this chapter.<br />

• For the software to be correct, it should produce the correct result regardless<br />

of the actual interleaving. That is, the correct result should be<br />

obtained for any interleaving (for given input sequences) that comply<br />

41

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

Saved successfully!

Ooh no, something went wrong!