11.07.2015 Views

Encyclopedia of Computer Science and Technology

Encyclopedia of Computer Science and Technology

Encyclopedia of Computer Science and Technology

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.

400 recursion<strong>and</strong> with the potential consequences <strong>of</strong> failure. An air trafficcontrol system may be able to take a few seconds betweenprocessing radar samples, but it better get it right in time.Systems like this where real-time response is absolutelycrucial are sometimes called “hard real-time systems.”Other systems are less critical. A streaming audio systemhas to keep its buffer full so it can play in real time,but if it stutters once in a while, no one’s life is in danger.(And since download rates over the Internet can vary formany reasons it’s not realistic to expect too perfect a level<strong>of</strong> performance.) A slower “s<strong>of</strong>t real-time system” like abank’s ATM system should be able to respond in tens <strong>of</strong> seconds,but if it doesn’t, the consequences are mainly potentialloss <strong>of</strong> customers <strong>and</strong> revenue. A fairly wide variation inresponse time may be acceptable as long waits don’t occur<strong>of</strong>ten enough to drive away too many customers.To put together the system, the engineer must look atthe inherent speed <strong>of</strong> the sampling device (such as radar,camera, or simply the keyboard buffer). The speed <strong>of</strong> theprocessor(s) <strong>and</strong> the time it takes to move data to <strong>and</strong> frommemory are also important. The structure, strengths, <strong>and</strong>weaknesses <strong>of</strong> the host operating system can also be a factor.Some operating systems (including some versions <strong>of</strong>UNIX) feature a guaranteed maximum response time forvarious operating system services. This can be used to helpcalculate the “worst case scenario”—that combination <strong>of</strong>inputs <strong>and</strong> the existing state <strong>of</strong> the system that should resultin the slowest response.Another approach available in most operating systems isto assign priority to parts <strong>of</strong> the processing so that the mostcritical situations are guaranteed to receive the attention <strong>of</strong>the system. However, things must be carefully tuned so thateven lower priority tasks are accomplished in an acceptablelength <strong>of</strong> time.The design <strong>of</strong> the data structure or database used tohold information about the process being monitored is alsoimportant. In most databases the age <strong>of</strong> the data is not thatimportant. For a payroll system, for example, it might besufficient to run a program once in a while to weed outpeople who are no longer employees. For a nuclear powerplant, if data is getting too old such that it’s not keepingup with current condition, some sort <strong>of</strong> alarm or evenautomatic shutdown might be in order. With a system thathas s<strong>of</strong>ter constraints (such as an automatic stock tradingsystem), it may be enough to be able to get most trades donewithin a specified time <strong>and</strong> to gather data about the performance<strong>of</strong> the system so the operators can decide whether itneeds improvement.Real-time systems are increasingly important because<strong>of</strong> the importance <strong>of</strong> the activities (such as air traffic control<strong>and</strong> power grids) entrusted to them, <strong>and</strong> because <strong>of</strong>their pervasive application in everything from cars to cellphones to medical monitors (see embedded system <strong>and</strong>medical applications <strong>of</strong> computers). The systems alsotend to be increasingly complex because <strong>of</strong> the increasinginterconnection <strong>of</strong> systems. For example, many real-timesystems have to interact with the Internet, with communicationsservices, <strong>and</strong> with ever more sophisticated multimediadisplay systems. Further, many real-time systems mustuse multiple processors (see multiprocessing), which canincrease the robustness <strong>and</strong> reliability <strong>of</strong> the system butalso the complexity <strong>of</strong> its architecture, <strong>and</strong> thus the difficultyin determining <strong>and</strong> ensuring reliability.Further ReadingButtazzo, Giorgio C. Hard Real-Time Computing Systems: PredictableScheduling Algorithms <strong>and</strong> Applications. 2nd ed. NewYork: Springer, 2005.Cheng, Albert M. K. Real-Time Systems: Scheduling, Analysis, <strong>and</strong>Verification. Hoboken, N.J.: Wiley, 2002.Resources for Real-Time Computing. TechRepublic. Availableonline. URL: http://search.techrepublic.com.com/search/real-time+computing.html. Accessed August 19, 2007.recursionEven beginning programmers are familiar with the ideathat a series <strong>of</strong> program statements can be executed repeatedlyas long as (or until) some condition is met (see loop).For example, consider this simple function in Pascal. Itcalculates the factorial <strong>of</strong> an integer, which is equal to theproduct <strong>of</strong> all the integers from 1 to the number. Thus factorial5, or 5! = 1 * 2 * 3 * 4 * 5 = 120.Function Factorial (n: integer) : integerBegini: integer;For i = 1 to n doFactorial := Factorial * i;End.If the main program has the line:Writelin (Factorial (5));then the 5 is sent to the function, where the loop simplymultiplies the numbers from 1 to 5 <strong>and</strong> returns 120.However, it is also possible to have a function call itselfrepeatedly until a specified condition is met. This is calledIn recursion, a procedure calls itself until some defined conditionis met. In this example <strong>of</strong> a Factorial procedure, F(1) is defined toreturn 1. Once it does, the returned value is plugged into its caller,which then returns the value <strong>of</strong> 1 * 2 to its caller, <strong>and</strong> so on.

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

Saved successfully!

Ooh no, something went wrong!