| Every time you turn on your computer it is multitasking | | | | won't fit many tasks into a mid-range PIC micro. |
| and all the tasks that the PC performs are done using | | | | Simple Multiple task scheduling |
| one instruction at a time. | | | | You can make a simple multiple task scheduler using |
| Multitasking simply means switching attention from one | | | | interrupts and careful coding and it won't need a huge |
| task to another to make it appear that many tasks | | | | amount of memory or resources. |
| are happening all at the same time. | | | | The advantage of this method is that you have full |
| To make it work in a PC the task manager shares out | | | | control over the code generated and can therefore fit |
| the processing time between each task giving it a set | | | | it into tiny devices. |
| amount of time and then moving on to the next task. | | | | The disadvantage is that you have to be completely |
| The key to its operation is the speed of the processor | | | | on top of how your code is working. With an RTOS |
| - the faster it is the more tasks it can handle and the | | | | time slices are assigned to each task giving them a fair |
| more complex they can be. For really difficult tasks a | | | | share of processing time. With this method you need |
| separate processor may be involved e.g. a graphics | | | | to decide how tasks are assigned processor time as |
| processor or a floating point co-processor (built into | | | | you design the code. |
| Pentium chips now). | | | | All you do is place all your code in an loop and use |
| You can use the same idea for a PIC microcontroller | | | | variables within the loop to test the conditions you |
| but since it is not going at GHz speeds you have to | | | | need e.g polling an input. Each test section is more or |
| carefully decide what tasks you need to do and how | | | | less equivalent to a task in an RTOS. |
| to make it work distributing a fair share of processing | | | | Interrupts |
| time to each task (or peripheral). | | | | As with any multitasking system the heart of a task |
| RTOS | | | | scheduler is the main timer that can assign time slices |
| An RTOS (Real Time Operating System) is the | | | | to each process. For this method a timer interrupt e.g. |
| ultimate multitasking system and it makes writing code | | | | Timer 0 operating every n milliseconds calls |
| easier using flag signals for inter-process | | | | subordinate functions that require the highest priority. |
| communication and provides prioritized task scheduling. | | | | Everything else is a low priority task that gets |
| The penalty for using an RTOS is that it takes up | | | | interrupted by the highest priority task. |
| code space and RAM resource (and there is a | | | | When you use this multitasking method you have to |
| learning curve as there are a lot of details for RTOS | | | | balance the processing time of the interrupt routine |
| control and task switching). | | | | against the processing needed by subordinate tasks |
| On the web you can find RTOS code for PIC micros | | | | so that enough time is spent doing the subordinate |
| but this is probably more appropriate for the larger 18F | | | | tasks. All this really means is make the ISR (Interrupt |
| series micros as RTOS's tend to require larger RAM | | | | Service Routine) as short as possible and as |
| and program resources (Ram is used to save all the | | | | infrequent as possible. |
| current task data between task switching) so you | | | | You can find more information from the website here. |