embedded.c

来自「嵌入式系统基础课件」· C语言 代码 · 共 51 行

C
51
字号
#include    <dos.h>
#include "libepc.h"
#include "os_cpu.h"
#include "os_cfg.h"
#include "ucos_ii.h"

#define TASK_STK_SIZE	1024

void Task1()
	{
	int n = 0 ;
	while (1)
		{
		OSSchedLock() ;
		SetCursorPosition(10, 30) ;
		PutString("Task #1: ") ;
		PutUnsigned(n++, 10, 10) ;
		OSSchedUnlock() ;
		OSTimeDly(10) ;
		}
	}

void Task2()
	{
	int n = 0 ;
	while (1)
		{
		OSSchedLock() ;
		SetCursorPosition(12, 30) ;
		PutString("Task #2: ") ;
		PutUnsigned(n--, 10, 10) ;
		OSSchedUnlock() ;
		OSTimeDly(10) ;
		}
	}

int main(void)
	{
	static OS_STK Task1Stk[TASK_STK_SIZE] ;
	static OS_STK Task2Stk[TASK_STK_SIZE] ;

	ClearScreen(0x07) ;
	OSInit() ;
	OSTaskCreate(Task1, NULL, &Task1Stk[TASK_STK_SIZE], 11) ;
	OSTaskCreate(Task2, NULL, &Task2Stk[TASK_STK_SIZE], 12) ;
	OSStart() ;

	return 0 ;
	}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?