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.

Object properties Implicit mutual exclusion of methods<br />

Thread Exec. state No Yes<br />

2.6. Models of concurrent execution<br />

Comment<br />

No No Object Monitor Passive objects<br />

No Yes Coroutine ’Co-monitor’ Not in Java<br />

5 6<br />

Yes No — —<br />

Not useful<br />

7 8<br />

Yes Yes Thread-object Task Active objects<br />

Figure 2.3: Fundamental properties of software execution. Language support<br />

for an execution property is marked with “yes”. For mutual exclusion to be<br />

supported, it must be implicitly obtained from the types or declarations.<br />

at a time may run the code of the object. This abstraction is called a<br />

monitor.<br />

3. Having an execution state without having a thread permanently associated<br />

with it forms an abstraction called a coroutine. A coroutine must<br />

be used by a thread to advance its execution state. If you have multiple<br />

coroutines but only one thread, only one coroutine at a time may<br />

execute. This is useful to handle parallellity issues in algorithms or in<br />

simulations because there the (virtual) time of the model can be held or<br />

advanced arbitrarily. That is, the real time used by a specific thread for<br />

its execution is unimportant, and a single thread using multiple coroutines<br />

is appropriate. An implementation based on coroutines can always<br />

be rewritten to work without them, but that may require more complex<br />

data structures and code. In combination with timer interrupts triggering<br />

a scheduler, coroutines can be used to implement thread objects.<br />

4. Adding mutual exclusion to coroutines is not really necessary in the case<br />

of just one thread, and in the case that a group of coroutines run by one<br />

thread interacts with other threads, this alternative leads to difficult and<br />

error-prone programming. The name co-monitor is not established and<br />

this case is neither used nor commented in the sequel.<br />

5. A thread without an execution state cannot execute on its own, and<br />

borrowing another thread for its execution does not provide concurrency.<br />

This case it therefore not useful.<br />

6. Also with mutual exclusion, this case is not useful for the reasons mentioned<br />

in item 5.<br />

7. An object with both thread and execution state is capable of execution of<br />

its own. We call this an active object or a thread object. The problem is<br />

that access to the attributes requires explicit mutual exclusion. That has<br />

to be simple to express in the program in order to make this alternative<br />

1<br />

3<br />

2<br />

4<br />

33

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

Saved successfully!

Ooh no, something went wrong!