Page 254 - Embedded Microprocessor Systems Real World Design
P. 254

Real-Time Operating Systems                                           9
















                 The theory and use  of a real-time operating system  (RTOS) can  and has taken
                 entire books. This chapter provides an overview.
                   As  embedded systems grow in complexity, they start to look more and more like
                 their  personal  computer  (PC) cousins. Software development  for  an embedded
                 system often is complicated by  the need to control system resources. In addition,
                 some embedded systems need to connect to Ethernet interfaces, harddisk drives,
                 and other PC-like peripherals. If all the software is written from scratch, code must
                 be written to interact with every device. For many standard interfaces, this is a dupli-
                 cation of the effort already expended by some other software engineer.
                   In  a  typical  embedded  system,  each  function  or  process  handles  its  own
                 resources, somewhat independent of the others. A process that interfaces to a host
                 system over an Ethernet link, for example, has memory allocated for its buffers. A
                 similar process may have code and buffers for an RS232 connection. The polling
                 loop gives each process control, one at a time, and each checks for data to or from
                 its respective interface.  But say that, in  this example system, the host uses either
                 Ethernet or RS-232, never both. In that case, the system really does not need both
                 pieces of code and both sets of buffers active at the same time. This system could
                 get by  with less RAM by  managing the memory, allocating whichever buffer is not
                 needed to other purposes.
                   In  addition  to  memory  management,  all  embedded  systems  must  schedule
                 processes in some manner. The polling loop method, sometimes called sequential
                 or ruund-robin scheduling, is probably the most common. In the pool timer example,
                 each  task  (motor on/off  control, time  rollover  handling,  keypad  processing)  is
                 given control one at a time. When motor control is finished, it passes control to
                 the  time rollover process, which subsequently hands it off to the keypad  (mode
                 control)  code, which returns to the  motor control code. Task  scheduling  is  one
                 big loop.
                   Although this method works well for simple systems like the pool timer, it has
                 some drawbacks. In the pool timer example, each task runs until it is finished. The
                 keypad processing code takes as much time as is needed to handle user inputs from


                                                                                      235
   249   250   251   252   253   254   255   256   257   258   259