本帖最后由 刘前辈 于 2011-12-8 20:32 编辑
M0版主别尽用简单的127个任务忽悠人,有本事别关中断,——任务用户没有控制权管理中断;像老刘这样写16个不同的任务,再写几个固定频率闪光流水灯同时输出。——哈哈,你关了中断,系统节拍(心脏)还跳吗?时钟还走吗?系统还是RTOS吗?固定频率闪光流水灯怎么办?硬实时任务怎么办?所长不是小孩子玩过家家。——和你一个人在家玩还行,忽悠大众就不行。
#include <REG51.H>
#include <stdio.h>
#include "os.h"
#include "task.h"
char *p=
"The compiler recognizes direct calls to interrupt \n"
"functions and rejects them.\n"
"It is pointless to call interrupt procedures directly,\n"
"because exiting the procedure causes execution of the RETI \n"
"instruction which affects the hardware interrupt system of \n"
"the 8051 chip. Because no interrupt request on the part of \n"
"the hardware existed, the effect of this instruction is \n"
"indeterminate and usually fatal.---Do not call an interrupt\n"
"function indirectly through a function pointer. \n\n";
void InitializeComPort()
{
SCON = 0x50;
TMOD |= 0x20;
TH1 = 0xF0;
TR1 = 1;
TI = 1;
}
char putchar (char c)
{
SBUF = c;
while (!TI);
TI =0;
return c;
}
void Test1()
{
while (1) {
id = GetCurrentTaskID();
printf("***** Test %d \n", (int) id);
WaitForSemaphore();
}
}
// …………
void Test15()
{
char id;
while (1) {
P1=~P1;
Sleep(500);
}
}
void Test16()
{
char id;
while (1) {
id = GetCurrentTaskID();
printf(p);
WaitForSemaphore();
}
}
void Test()
{
char c;
while (1) {
while (!RI);
RI = 0;
c = SBUF;
SetSemaphore(c-'a'+1);
}
}
、、 |