⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.c

📁 uCOS-II ports on Tensilica HiFi330 core.
💻 C
字号:
#include "includes.h"
#include "timer.h"
#include "interrupts.h"
#include <xtensa/simcall.h>
#include <xtensa/tie/xt_core.h>

#define TASK_NUM		3
#define TASK_STK_SIZE	10000
#define TASK_1_PRIO		3
#define TASK_2_PRIO		4
#define TASK_3_PRIO		5

OS_STK   TestTaskStk[TASK_NUM][TASK_STK_SIZE];



int global_fool_the_optimizer = 0;
#define DELAY 1000

void deep_call (int depth)
{
	volatile temp;
	int a = depth;
	int b = depth + 1;
	int c = depth + 2;
	int d = depth + 3;


	if (global_fool_the_optimizer)
	{
		a=b=c=d=10;
	}

for (temp=0;temp<DELAY;temp++){;}

if ( depth > 0)
	deep_call (depth -1 );
	
if ((a != depth) || (b != depth + 1) || (c != depth + 2) || (d != depth+3))
	{
		OSSchedLock();
		printf("------failed------- \n");
		OSSchedUnlock();
	}
}

void Task1(void *pdata)
{
	
	volatile count = 0;	


	for(;;)
	{
		count++;

		OSSchedLock();
        printf("Task I - starting - %d\n", count);
		OSSchedUnlock();

		deep_call(10);

		OSSchedLock();
        printf("Task I - ending - %d\n", count);
		OSSchedUnlock();

		OSTimeDly(30);
	}
}


void Task2(void *pdata)
{
	
	volatile count = 0;

	for(;;)
	{
		count++;

		OSSchedLock();
        printf("\tTask II - starting - %d\n", count);
		OSSchedUnlock();

		deep_call(20);

		OSSchedLock();
        printf("\tTask II - ending - %d\n", count);
		OSSchedUnlock();

		OSTimeDly(25);
	}
}

void Task3(void *pdata)
{
	
	volatile count = 0;

	for(;;)
	{
		count++;

		OSSchedLock();
        printf("\t\tTask III - starting - %d\n", count);
		OSSchedUnlock();

	    deep_call(30);
		OSSchedLock();
        printf("\t\tTask III - ending - %d\n", count);
		OSSchedUnlock();
		
		OSTimeDly(10);
	}
}



int main(void)
{
	
	OSInit();
	
	OSTaskCreate(Task1, (void *)0, &TestTaskStk[0][TASK_STK_SIZE], TASK_1_PRIO);
	OSTaskCreate(Task2, (void *)0, &TestTaskStk[1][TASK_STK_SIZE], TASK_2_PRIO);
	OSTaskCreate(Task3, (void *)0, &TestTaskStk[2][TASK_STK_SIZE], TASK_3_PRIO);
	
	
	OSStart();
	
	return(0);
}

⌨️ 快捷键说明

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