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. Fundamentals<br />
point. We may say that the system forces the application to give up the use<br />
of the CPU.<br />
The opposite to pre-emptive scheduling is non-pre-emptive scheduling,<br />
which means that execution is only suspended when there is some call of<br />
scheduling functions or resource allocation. For instance, an attempt to open<br />
a network connection may include waiting for name-servers and remote computers<br />
to reply. Even if it is not desirable to wait, we know (and the compiler<br />
and run-time system knows) that execution may very well be suspended.<br />
These so called blocking operations are handled the same when pre-emption<br />
is used, but with pre-emption the suspension may also be enforced.<br />
Different types of pre-emption exist. In general terms, there are three<br />
alternatives for the granularity of execution suspension:<br />
1. The most primitive case is when pre-emption is not supported; execution<br />
is only suspended when certain system calls are made. The advantage is<br />
efficiency since the state of the execution is well known by the compiler<br />
and run-time system. For instance, all temporary registers that by the<br />
compiler are assumed to be destroyed by a function call, need not be<br />
saved. The disadvantage is that an application (or function) written<br />
without considering the need for other activities to execute concurrently<br />
will not give up the right to use the CPU, and may therefore lock the<br />
system or make response times too long.<br />
2. Execution may be interrupted/suspended between each line of source<br />
code. From a programming point of view, it is very convenient to know<br />
that each statement gets fully executed without interrupt. Early-days<br />
Basic interpreters often worked this way. One disadvantage is that complex<br />
statements may delay change of activity too long. Not to interfere<br />
with other interrupt services, interrupts such as the timer interrupt is<br />
served immediately and ongoing execution may be marked for suspension.<br />
Another disadvantage is then that the checking between each statement<br />
costs processing power. An interesting version of this technique<br />
is implemented in the Lund Simula system which by utilization of the<br />
hardware (Sun Sparc) performs the check at almost no cost. The key<br />
drawback is, however, that concurrency requires support from compiler<br />
and run-time system, which means that most available code (written in<br />
C/C++) cannot be used when timing requirements are severe.<br />
3. Execution may be interrupted/suspended between each machine instruction.<br />
The advantages are that any sequential code (without compiler<br />
support) can be interrupted, and that the interrupt and possible rescheduling<br />
will be started immediately. There will, however, be some delay since<br />
we must save the entire status of the execution (all registers etc.), and<br />
that may for some types of hardware be slower than case 2. Another<br />
28 2012-08-29 16:05