我们再来添加一个任务,首先添加一个进程体:

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)

运行结果如下:

操作系统开发系列—13.e.三进程

我们把现在的添加任务的步骤总结一下:

1.在task_table中增加一项(global.c)

2.让NR_TASKS加1(proc.h)

3.定义任务堆栈(proc.h)

4.修改STACK_SIZE_TOTAL(proc.h)

5.添加新任务执行体的函数声明(proto.h)

 

源码

相关文章:

  • 2021-11-26
  • 2021-10-23
  • 2021-11-21
  • 2021-07-03
  • 2021-07-31
  • 2021-11-11
  • 2021-05-21
猜你喜欢
  • 2021-07-09
  • 2022-03-03
  • 2022-01-18
  • 2022-01-11
  • 2021-12-16
  • 2022-01-16
  • 2021-12-08
相关资源
相似解决方案