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.4. Concurrency<br />

a trend that the parallelity is fully taken care of by the hardware. Hardware<br />

developers talk about the “sequence control barrier” which means<br />

that the hardware parallelity may not violate the sequencing property<br />

of the software execution as described in Section2.1. Thus, even if we<br />

should use a PC running Windows on four CPUs, we do not have to<br />

care about that when writing our software.<br />

In conclusion, the sequential execution model described earlier is almost always<br />

valid even when parallel computers are used. Comments about software<br />

interfaces between different processors will be given in a few places in this<br />

book, but generally we should think in terms of using a single CPU.<br />

2.4 Concurrency<br />

Our software applications interact with users and external equipment via input/output<br />

interfaces, generally called the IO. The computer receives input<br />

data concurrently from sensors and from user input devices like keyboard,<br />

mouse, and microphone, as depicted in Figure 2.2. From the user we talk<br />

about input events, and from the sensors we talk about samples. Both input<br />

events and samples reach our program in form of some kind of data entity<br />

or record. For a mouse click, for example, the event typically contains the<br />

horizontal and vertical coordinates on the screen and the time when the click<br />

occurred. Sampled physical values for feedback control are usually obtained<br />

via dedicated IO interfaces with well defined timing and buffering; extra delays<br />

in terms of unforeseen buffering could cause the feedback control to be<br />

unstable. There is no clear distinction between the two loops in Figure 2.2<br />

(for instance real-time games only have one type of loop and physics is directly<br />

available to the user/driver in vehicles), but it is normally good to be<br />

aware of it for engineering purposes. Assume we only know ordinary sequential<br />

programming. Even if we use object oriented design and programming,<br />

with classes and objects defined according to real-world objects, methods are<br />

sequential and called sequentially so we still have the same situation as commented<br />

in the beginning of this chapter. Physically, all input may occur in<br />

parallel, and we can generally not make any assumptions about the resulting<br />

order of the data that is input to our program. The problem with pure<br />

sequential programming is that the programmer must define in what order<br />

computing should be done, but it is not known in what order input data<br />

will arrive, or the program has to waste CPU time on excessive polling and<br />

evaluation of conditions that may influence the output.<br />

For example, reconsider the LEGO-brick machine. Assume we have implemented<br />

the control program as one loop in which all IO and control is<br />

carried out sequentially. Then consider what the changes will be if, say, the<br />

sampling frequency of the temperature control is substantially changed. Since<br />

21

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

Saved successfully!

Ooh no, something went wrong!