JAVA-BASED REAL-TIME PROGRAMMING
JAVA-BASED REAL-TIME PROGRAMMING
JAVA-BASED REAL-TIME PROGRAMMING
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
2.6. Models of concurrent execution<br />
• An SP (the Stack Pointer) which refers to the stack of that particular<br />
execution sequence. On the stack, there are the activation records of<br />
all blocks/functions that are currently entered, as required for reentrant<br />
code.<br />
• The machine state (of the CPU or some virtual machine depending on<br />
the implementation of the run-time system) holds part of the status of<br />
our execution sequence.<br />
• If common resources (like shared data) are reserved in one sequence,<br />
that affects the others and should therefore be dealt with somehow.<br />
Continuing our attempt to bring order in the complexity by exploring fundamental<br />
properties, some basic terms will now be described. First we have the<br />
following two definitions:<br />
Definition: A context is the state of an active program execution, which<br />
includes PC, SP, and machine state. From an operating system point of view,<br />
execution may also be associated with permission and user privileges which<br />
then may be included in the context. In such a case we call it a process context<br />
or a heavy-weight context. From this point on, we will use the former minimal<br />
definition which is also called a light-weight context.<br />
Definition: A context switch refers to the change of context typically performed<br />
by some scheduler or operating system.<br />
Since we aim at appropriate programming methods, there is the question<br />
about what support we have from the language and from the programming<br />
interfaces (libraries of available classes). This has a great impact on the way<br />
we have to write our code. For instance, when programming in C, the language<br />
itself does not give any support for handling concurrency which makes the use<br />
of special libraries important (and tricky). In Ada there is language support in<br />
terms of tasks and rendezvous, but using that support has a significant impact<br />
on both design and implementation. A language with extensive support, like<br />
Occam, is in danger of being too special and therefore not being widely used.<br />
2.6.1 Fundamental abstractions<br />
The question now is, to what extend should a general purpose programming<br />
language support concurrency? As suggested by Buhr in a proposed extensions<br />
of C++, it is appropriate to separate the context from the execution sequence<br />
as such, and the following execution properties should be supported by the<br />
language:<br />
Thread - is execution of code that occurs independently and possibly concurrent<br />
with other execution. The execution resulting from one thread is<br />
sequential as expressed in ordinary programming languages such as Java. Multiple<br />
threads provide concurrent execution. A programming language should<br />
provide features that support creation of new threads and specification of how<br />
31