JAVA-BASED REAL-TIME PROGRAMMING
JAVA-BASED REAL-TIME PROGRAMMING
JAVA-BASED REAL-TIME PROGRAMMING
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
2. Fundamentals<br />
these threads accomplish execution. Furthermore, there must be programming<br />
language constructs whose execution causes threads to block and subsequently<br />
be made ready for execution. A thread is either blocked or running or ready.<br />
A thread is blocked when it is waiting for some event to occur. A thread is<br />
running when it is actually executing on a processor. A thread is ready when<br />
it is eligible for execution but is not being executed.<br />
Execution state - is the state information needed to permit concurrent execution.<br />
An execution state can be active or inactive, depending on whether<br />
or not it is currently being used by a thread. An execution state consists of<br />
the context and the activation state. These are typically stored (internally in<br />
the run-time system) in a data structure, which traditionally has been called<br />
process control block/record (PCR). An inactive execution state is then completely<br />
stored within the PCR, whereas the hardware related parts (registers,<br />
interrupt masks, etc.) of an active execution state are stored in the hardware/CPU.<br />
Referring to the context as the main item, we call the change<br />
between the active and inactive states a context switch. The switch includes<br />
storing or restoring the hardware state, and it occurs when the thread transfers<br />
from one execution state to another.<br />
Mutual exclusion - is the mechanism that permits an action to be performed<br />
on a resource without interruption by other operations on that resource.<br />
In a concurrent system, mutual exclusion is required to guarantee<br />
consistent generation of results, and it should therefore be supported in a convenient<br />
way by the programming language. Furthermore, for efficiency at run<br />
time, it needs to be provided as an elementary execution property.<br />
In an object-oriented framework, these three execution properties are properties<br />
of objects. Therefore, an object may or may not have/be a thread, it<br />
may or may not have an execution state, and it may or may not have/provide<br />
mutual exclusion. The latter means that it may or may not exclude concurrent<br />
access via call of methods of that object. The next issue is to know: What are<br />
the possible and useful combinations of the execution properties? All eight<br />
combinations (which would make up a 2 by 2 by 2 cube) is depicted in Figure<br />
2.3. The numbers in that table refers to the following items:<br />
1. This is an ordinary object as known from object oriented programming,<br />
or an ordinary piece of code in the case that object orientation is not<br />
supported. This is the only case that programmers not acquainted with<br />
concurrent programming use. A class programmed in this way can still<br />
be useful in an concurrent environment if its member functions are reentrant,<br />
which they are if only local data is used and the if language/execution<br />
supports recursion (direct or indirect). Since there is neither a<br />
thread nor an execution state, we say that the object is a passive object.<br />
2. It is still a passive object if we add mutual exclusion, but only one thread<br />
32 2012-08-29 16:05