title: How to achieve multitasking in a microcontroller?
body: <p>I wrote a program for a wrist watch utilizing a 8051 micro-controller using Embedded (C). There are a total of 6 7-segment displays as such:</p>
  
  <pre><code>         _______________________
          |      |       |        |   two 7-segments for showing HOURS
          | HR   | MIN   |   SEC  |   two 7-segments for showing MINUTES and
          |______._______.________|   two 7-segments for showing SECONDS
            7-segment LED display
  </code></pre>
  
  <p>To update the hours, minutes and seconds, we used 3 <code>for</code> loops. That means that first the seconds will update, then the minutes, and then the hours. Then I asked my professor why can't we update simultaneously (I mean hours increment after an hour without waiting for the minutes to update). He told me we can't do parallel processing because of the <i>sequential execution</i> of the instructions. </p>
  
  <p>Question:</p>
  
  <p>A digital birthday card which will play music continuously whilst blinking LED's simultaneously. A digital alarm clock will produce beeps at particular time. While it is producing sound, the time will continue updating. So sound and time increments both are running in parallel. How did they achieve these results with sequential execution?</p>
  
  <p>How does one run multiple tasks simultaneously (scheduling) in a micro-controller?</p>