操作系统开发系列—13.e.三进程
我们再来添加一个任务,首先添加一个进程体:
void TestC() { int i = 0x2000; while(1){ disp_str("C"); disp_int(i++); disp_str("."); delay(1); } }void TestC() { int i = 0x2000; while(1){ disp_str("C"); disp_int(i++); disp_str("."); delay(1); } }
然后在global.c:
PUBLIC TASK task_table[NR_TASKS] = { {TestA, STACK_SIZE_TESTA, "TestA"}, {TestB, STACK_SIZE_TESTB, "TestB"}, {TestC, STACK_SIZE_TESTC, "TestC"}};PUBLIC TASK task_table[NR_TASKS] = { {TestA, STACK_SIZE_TESTA, "TestA"}, {TestB, STACK_SIZE_TESTB, "TestB"}, {TestC, STACK_SIZE_TESTC, "TestC"}};
然后是proc.h:
/* Number of tasks */ #define NR_TASKS 3 /* stacks of tasks */ #define STACK_SIZE_TESTA 0x8000 #define STACK_SIZE_TESTB 0x8000 #define STACK_SIZE_TESTC 0x8000 #define STACK_SIZE_TOTAL (STACK_SIZE_TESTA + STACK_SIZE_TESTB + STACK_SIZE_TESTC)/* Number of tasks */ #define NR_TASKS 3 /* stacks of tasks */ #define STACK_SIZE_TESTA 0x8000 #define STACK_SIZE_TESTB 0x8000 #define STACK_SIZE_TESTC 0x8000 #define STACK_SIZE_TOTAL (STACK_SIZE_TESTA + STACK_SIZE_TESTB + STACK_SIZE_TESTC)
运行结果如下:
我们把现在的添加任务的步骤总结一下:
1.在task_table中增加一项(global.c)
2.让NR_TASKS加1(proc.h)
3.定义任务堆栈(proc.h)
4.修改STACK_SIZE_TOTAL(proc.h)
5.添加新任务执行体的函数声明(proto.h)
【】
我们再来添加一个任务,首先添加一个进程体: void TestC() { int i = 0x2000; while(1){ disp_str("C"); disp_int(i++); disp_str("."); delay(1); } } 然后在global.c: PUBLIC TASK task_table[NR_TASKS] = { {TestA, STACK_SIZE_TESTA, "TestA"}, {TestB, STACK_SIZE_TESTB, "TestB"}, {TestC, STACK_SIZE_TESTC, "TestC"}}; 然后是proc.h: /* Number of tasks */ #define NR_TASKS 3 /* stacks of tasks */ #define STACK_SIZE_TESTA 0x8000 #define STACK_SIZE_TESTB 0x8000 #define STACK_SIZE_TESTC 0x8000 #define STACK_SIZE_TOTAL (STACK_SIZE_TESTA + STACK_SIZE_TESTB + STACK_SIZE_TESTC) 运行结果如下: 我们把现在的添加任务的步骤总结一下: 1.在task_table中增加一项(global.c) 2.让NR_TASKS加1(proc.h) 3.定义任务堆栈(proc.h) 4.修改STACK_SIZE_TOTAL(proc.h) 5.添加新任务执行体的函数声明(proto.h) 【】