?? multitask.c
字號:
#include <string.h>
#include "includes.h"
#include "consol.h"
#define TASK_STK_SIZE 256 /* Size of each task's stacks (# of WORDs) */
#define NO_TASKS 10 /* Number of identical tasks */
static OS_STK TaskStk[NO_TASKS][TASK_STK_SIZE]; /* Tasks stacks */
//-----------------------------------------------
//
static void WriteString(char *str)
{//寫字符串
CONSOL_Printf(str);
}
//-----------------------------------------------
static void Task1 (void *Task)
{
char str[8];
sprintf(str, "%d", (int)Task);
while(1)
{
WriteString(str);
OSTimeDly(500);
}
// OSTaskDel(OS_PRIO_SELF);//刪除自己
}
#define PRIO_BASE 30
void RunTestMultitask()
{
char key='+';
int i=0;
WriteString("**多任務的使用** <按ESC鍵結束測試>\n");
WriteString(" <按'+'添加一個任務>\n");
WriteString(" <按'-'減少一個任務>\n");
OSTimeDly(2000);
WriteString("\n按任意鍵開始\n");
CONSOL_GetCh();
while(key != 0x1b)
{
switch(key)
{
case '+':
if(i < 10)
{
OSTaskCreate(Task1, (void*)i, (void*)&TaskStk[i][TASK_STK_SIZE-1], PRIO_BASE+i);
i++;
}
break;
case '-':
if(i > 0)
OSTaskDel(PRIO_BASE+(i--));
break;
}
key = 0;
CONSOL_GetChar(&key);
OSTimeDly(100);
}
OSTimeDly(500);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -