Page 130 - Anatomy of a Robot
P. 130

03_200256_CH03/Bergren  4/17/03  12:27 PM  Page 115
                                                                               COMPUTER HARDWARE 115
                            Compute Crunch
                            It is quite difficult to get a sense of the amount of work the processor must perform in
                            real time. The processor will be executing instructions at full speed unless it is asked to
                            rest as part of saving power. During the time it is running instructions, it can only per-
                            form a discrete number of calculations per second. The amount of work the processor
                            can do is therefore limited. It is a fine art to be able to estimate how much work any one
                            processor can accomplish. The following should be considered during this process.


                            Algorithms  Perform an analysis of the control algorithms and determine how many
                            instructions per second must be executed to accomplish the work required. If, for
                            instance, we know that the algorithm requires the processor to perform 5,000 instruc-
                            tions every 20 milliseconds, we have a measure of how busy it will be. It will be exe-
                            cuting at least 250,000 instructions per second (5000/.020). If the processor is capable
                            of executing 1 million instructions per second, then about 25 percent of its time will be
                            devoted to the algorithm in question.
                              Next, we can take a look at all the other algorithms the processor must execute and
                            determine how much of the processor time they will consume. Simply add up the per-
                            centages to get a gauge of how busy the processor will be. As a general rule of thumb,
                            don’t count on being able to load the processor down more than 50 percent. All proces-
                            sors will have housekeeping tasks to perform that cannot be easily accounted for.
                              Further, the more often any one algorithm is executed, the more overhead it will require.
                            Simplifying matters somewhat, it can be stated that a fixed amount of processor time is
                            required to execute any one algorithm once. If we make the algorithm shorter but have to
                            execute it more often, the processor will lose efficiency. Let’s look at an extreme example.
                              Suppose, for example, that the processor must execute 100,000 addition instructions
                            once a second. Suppose further that it requires 10 instructions just to kick off an algorithm.
                              Algorithm A executes 100,000 additions at the same time. To accomplish the required
                            100,000 additions per second using algorithm A, the processor must execute 100,010
                            instructions per second (1   (100,000   10)).
                              Algorithm B executes 100 additions every millisecond. To accomplish the required
                            100,000 additions per second using algorithm B, the processor must execute 110,000
                            instructions per second (1000   (100   10)).
                              Algorithm A will be much more efficient of the processor’s time, about 10 percent
                            more efficient than algorithm B. We’ll study the various methods of setting up control
                            algorithms in a later chapter.


                            Operations per Second  Most computers are capable of executing many instructions
                            every second. Often, this number is given in millions of instructions per second (MIPS).
   125   126   127   128   129   130   131   132   133   134   135