Professional Documents
Culture Documents
Design Issues in RTS
Design Issues in RTS
A simple program
Fig. 1
system operating criteria, including timing constraints, is so important. Real-time systems are often reactive or embedded systems. Reactive systems are those which have some ongoing interaction with their environment, for example a fire-control system which constantly reacts to buttons pressed by a pilot. Embedded systems are those used to control specialized hardware and lack an operating system and associated devices for general user interface. For example the microprocessor system residing in many automobiles used to control the fuel/air mixture in the carburetor is clearly embedded. Similarly, the software used to control the Inertial Measurement Unit of the Space Shuttle is highly embedded. Incidentally. systems that are not embedded are sometimes called orgcrizic. sytetns if they are not designed for a specialized hardware application. and loosely coupled or semidetuched if they can be made easily organic with the rewrite of a few modules. Of course our three previous examples satisfy the criteria for a real-time system precisely. An aircraft must process accelerometer data within a certain period that depends on the specifications of the aircraft. for example every I O milliseconds ( I O thousandths of a second). Failure to do so could result in
24
IEEE POTENTIALS
fl ow - of - c o n t ro 1'? Consider the flow Example chart in Figure 1. The decision block represented by the triangle suggests that the stream of prognm instructions, like water flowing through a pipe into a Yshaped joint. can take one of two paths depending on the response to the question. IF-THEN, G O T 0 and CASE statements in any language represent possible changes in flow-of-control. Statements such as subroutine calls in FORTRAN and invocation of procedures in C, Pascal or Ada represent changes in flow-ofcontrol. In general. any occurrence that causes the program counter to change Interrupt Driven System non-sequentially is considered a change of flow-of-control and thus an event. We will see momentarily that hardware signals can cause a change in flow-of-control and thus are events. Events can be divided into two categorie s : s ~ r i c r o n o ~ ~ s a s y ch r o ~ ~ o i ~ s . h and Synchronous events are those that occur at predictable times in the tlow-of-control-such as at the decision box in the Fig. 3 flow chart. You can anticipate this change of tlow-of-control (although it may not always happen). Asynchronous events occur at unpredictable points in tines) or through the use of interrupts. In interrupt-drirwl systems, a set of interrupt the flow-of-control and are usually handlers are installed during initialization, while the main program consists of a simple caused by eternal sources. jump-to-self loop. Interrupts cause the interrupt handler to be invoked in order to react A clock that pulses "regularly" at 5 to the associated event (see Figure 3). Foregroiirio'/BackSrr,llrld systems are an improvement over purely interrupt driven milliseconds is not a synchronous event. systems and are the most common solution for embedded real-time applications. In these Even if the clock could tick at a perfect systems. the simple jump-to-self loop is replaced by non-time-critical code called the 5 milliseconds without drift (which it hrickgroiind. The interrupt driven processes are called theji,reground. The background cannot for physical reasons). where the task is fully preemptable by any foreground task and in a sense. represents the lowest tick occurs within the flow-of-control is priority task in the system. The aircraft navigation system can be set up using the foregroundhackground scheme. essentially random. You can never count The five main process cycles, asynchronous 30ms. 5ms, loins. 40ms, and one second, on a clock ticking exactly at the rate are set up as foreground processes. The background process is used for slow built in test specified and must design any system software such as a CPU check and other non-time-critical processing such as data logging with that in mind. or screen update. It is common to increment acounter in background to provide a measure I n an! +! stem, but especially a realof time-loading or to detect if any foreground proces+ has locked up. For example. a counter is provided for each of the foreground processes, and is reset time system. maintaining control is exby its respective process. If the background detects that one of the counters is not being tremely important. For any physical reset. the corresponding task is assumed to be locked and a failure can be indicated. system there are certain states under Foreground/background systems are the best kernel choice when the number of real-time which the system is considered to be"out tasks i s fixed. Unfortunately, these systemb are vulnerable to timing variations, unanticiof control." The software controlling pated race conditions and hardware failures. For this reason some companies avoid designs based on interrupts altogether. -PAL such a system must avoid these states. For example. in certain guidance systems for robots o r aircraft, rapid rotation the program and not the data area of dict the next state of the system given through a 180' pitch angle can cause a memory. The latter case can occur in the current state and a set of inputs. In physical loss of gyro control. The softpoorly tested systems and is a catastroother words, one wishes to predict how ware must be able to foresee and prepare phe from which there is almost no hope r ~ ~ : ~ t.!.illi - r l-i-hx.i- i n 211 pcvihlc cirfor this situation or risk losing control. Another characteristic of a controlled software system is that the computer is fetching ancl executing instructions from
FEBRUARY 1993
25
One final concept needs to be introduced because i t is Problem Solution(s) Possible often used as a measurement of Drawback real-time system performance. Time-lotrdirig, or the u t i l i w System model- dataflow cannot depict ing and design diagrams control flow tioii,fuctoi: is a measure of the percentage of useful procSuitable Ada poor and essing the computer is doing. programming unpredictable languages performance A system is said to be tirnrovc~rloudeclif it is 100% or Kernel selection commercial poor and tnore time-loaded. Time-loadproducts unpredictable performance ing differs from CPU throughput. which is a measure of the Inter-task mailboxes, degrade number of macro instructions communication queues performance per second that can be procInter-task semaphores deadlock essed based on some pre-detersvnchronization mined instruction mix. Memory dynamic fragmentation, This type of measurement management allocation degraded is typically used to compare performance CPU horsepower for some Testing test not feasible particular application. Recall everything that a CPU is constantly busy with the fetch-execute cycle even when idling (its executcumstances. A system is said to be deing a dummy instruction called a 1 1 0 terministic if for each possible state. and op).lfthe computer is never idling, that each set of inputs, a unique set of outputs is it executes no no-ops. then it is 100% and next state of the system can be detertime-loaded. mined. Systems which are too highly timeIn particular, a certain kind of deterloaded. say 98%. are undesirable beminism called event deternzirzisiii means cause changes or additions cannot be that the next states and outputs of sysmade to the system without risk of tem are known for each set of inputs t i me - o v er I o ad i n g . S y s te m s which which trigger events. Thus, a system have low time-loading factors, say which is deterministic is event determi10%. are not necessarily good because nistic. While it would be difficult for a this may imply that the processor and system to be deterministic only for those related hardware may be too powerful inputs which trigger events. this is plaufor the application. This means that sible and so event determinism may not perhaps costs can be reduced by proimply determinism. We are, however. curing a less powerful processor. only interested in pure deterministic There is no magic number for timesystems. Finally, if in a deterministic loading. While 50% is common for system the response time for each set of new products and 80% is acceptable outputs is known. then the system also for systems which do not expect exhibits tempor-ul deternziriisni. growth. 70% as a desired time-loading Each of these previous definitions of figure is well grounded in theory. determinism imply that the system must have a finite number of states. This is a Real-time design issues reasonable assumption to make in a Why study real-time systems? The digital computer system where all indesign and implementation ofreal-time puts are digitized to within a finite systems requires the careful considerarange. One side benefit of designing tion of a variety of issues. Among the deterministic systems is that one can tasks facing the real-time system deguarantee that the system can respond at \igner are: any time, and in the case of temporally I . The helection of hardware and deterministic systems, when they will software and the appropriate mix respond. This reinforces the association needed for a cost-effective solution. of control with real-time systems.
Table 1
2. The decision to take advantage of a commercial real-time operating system or to design a special operating system. 3. The prediction and measurement of time-loading and its reduction. 4. The selection ofan appropriate software language for system development. 5. The maximizing of system faulttolerance and reliability through careful design and rigorous testing. 6. The design and administration of tests and the selection of test and development equipment. Addressing these issues for large or even modest projects can present a staggering task. Table 1 lists some other problem issues in real-time system design. possible solutions and their potential drawbacks. Finally, the techniques you learn by building real-time systems enable you to develop non-real-time systems that are more efficient, reliable, and maintainable.
26
IEEE POTENTIALS