Page 42 - Designing Autonomous Mobile Robots : Inside the Mindo f an Intellegent Machine
P. 42

The Basics of Real-time Software (For Mere Mortals)

               its execution resumes. This is no more complicated than putting all your work onto
               a stack on your desk when a visitor arrives, and when they leave, taking it back off
               and resuming what you were doing.



                              Stack Pointer



                          Previously
                         Stored Data  Unused    Unused     Unused     Unused     Unused

                                           Stack Memory Before Interrupt
                                         Stack Pointer



                                   Address where
                          Previously
                         Stored Data  Program was  Unused  Unused     Unused     Unused
                                    Interrupted
                                         Stack Memory After Interrupt Event





                          Previously
                                     Unused     Unused     Unused     Unused     Unused
                         Stored Data
                                      Stack Memory After Return from Interrupt

                  Figure 3.1. A simplified representation of stack operations during interrupts




               The interrupt vector is the address to which the program will jump automatically
               when an interrupt occurs. This interrupt vector must have been set to point to a valid
               interrupt handler routine before the interrupt was enabled or the computer may begin
               trying to read and execute memory that is not valid. This has an effect similar to
               trying to assemble Christmas toys by discarding the instructions and reading the
               Kama Sutra instead; it is amusing but fraught with hazard. The technical term for
               this condition is going off into the woodwork. It can cause some very strange behavior.










                                                        25
   37   38   39   40   41   42   43   44   45   46   47