Download Salvo User Manual
Transcript
which re-initialized its local variables and succeeded in printing its
entire 36-character string ("Now we … interrupt.\n"). After the
ISR finished, the main-loop printf() resumed where it had left
off, but its internal variables reflected having successfully written
to the end of a string argument, and no further output appeared
necessary, so it simply returned and the main loop continued executing.
Note Calling non-reentrant functions as if they were reentrant
rarely results in such benign behavior.
Various techniques can be employed to avoid this problem of a
non-reentrant printf(). One is to disable interrupts before calling
a non-reentrant function and to re-enable them thereafter. Another
is to rewrite printf() to only use local variables (i.e. variables
that are kept on the function's stack). The stack plays a very important role in reentrant functions.
Resources
A resource is something within your program that can be used by
other parts of the program. A resource might be a register, a variable or a data structure, or it might be something physical like an
LCD or a beeper. A shared resource is a resource that may be used
by more than one part of your program. If two separate parts of a
program are contending for the same resource, you'll need to manage this by mutual exclusion. Whenever a part of your program
wants to use the resource it must obtain exclusive access to it in
order to avoid corrupting it.
Multitasking and Context Switching
Many advantages can be realized by splitting a foreground / background application into one with multiple, independent tasks. In
order to multitask, such that all tasks appear to run concurrently,
some mechanism must exist to pass control of the processor and its
resources from one task to another. This is the job of the scheduler,
part of the kernel that (among its other duties) suspends one task
and resumes another when certain conditions are met. It does this
by storing the program counter for one task and restoring the program counter for another. The faster the scheduler is able to switch
tasks, the better the performance of the overall application, since
the time spent switching tasks is time spent without any tasks running.
16
Chapter 2 • RTOS Fundamentals
Salvo User Manual
Related documents
Salvo User Manual
Salvo User Manual
Release Notes
AN-4 Building a Salvo Application with HI-TECH
RM-HTARCLITE Salvo Compiler Reference Manual
Realtime Kernel Implantation in a PIC Microcontroller
Using the RTOS on TI`s MSP430
RM-IAR18 Salvo Compiler Reference Manual – IAR
RM-KC51 Salvo Compiler Reference Manual – Keil
Centurion G-SPEAK Installation manual