Download Salvo User Manual
Transcript
Tut3: Adding Functionality to Tasks
Listing 25 shows a multitasking application with two tasks that do
more than just context switch. We'll use more descriptive task
names this time.
#include "main.h"
#include <salvo.h>
unsigned int counter;
void TaskCount( void )
{
while (1) {
counter++;
OS_Yield();
}
}
void TaskShow( void )
{
InitPORT();
while (1) {
PORT = (PORT & ~0xFE)|((counter >> 8) & 0xFE);
OS_Yield();
}
}
int main( void )
{
Init();
OSInit();
OSCreateTask(TaskCount, OSTCBP(1), 10);
OSCreateTask(TaskShow, OSTCBP(2), 10);
counter = 0;
while (1) {
OSSched();
}
}
Listing 25: Multitasking with two Non-trivial Tasks
The two tasks in Listing 25 run independently of each other, and
they both access a shared global variable, a 16-bit counter. The
counter is initialized28 before multitasking begins. The first task
28
68
Strictly speaking, this initialization is unnecessary, as all ANSI compilers will
set counter to 0 before main().
Chapter 4 • Tutorial
Salvo User Manual
Related documents
Salvo User Manual
Salvo User Manual
Whirlpool REP3622B Specifications
RM-MSCX86 Salvo Compiler Reference Manual
AVR-GCC - Pumpkin, Inc.
AN-13 Building a Salvo Application with Keil`s C51 C Compiler and
Application Note
Release Notes
RM-MCC18 Salvo Compiler Reference Manual
IBM 5x86C Microprocessor BIOS Writer`s Guide
AN-4 Building a Salvo Application with HI-TECH
RM-HTARCLITE Salvo Compiler Reference Manual