Home > other >  UCOS transplant to VS2015 after open after statistical task CPU utilization has been to 0
UCOS transplant to VS2015 after open after statistical task CPU utilization has been to 0

Time:09-27

The source code below
# include "SystemConfig. H"

////////////////////////UCOSII task set///////////////////////////////////
//START the task
//set the task priority
10//# define START_TASK_PRIO task priority set to minimum
//set the task stack size
# define START_STK_SIZE 64
//task stack
OS_STK START_TASK_STK [START_STK_SIZE];
//task function
Void start_task (void * pdata);

//App1 task
//set the task priority
# define App1_TASK_PRIO 7
//set the task stack size
# define App1_STK_SIZE 64
//task stack
OS_STK App1_Task_Stk [App1_STK_SIZE];
//task function
Void App1Task (void * pdata);



Int main (void)
{
OSInit (); System initialization/* */
OSTaskCreate (start_task, (void *) 0, & amp; START_TASK_STK] [START_STK_SIZE - 1, START_TASK_PRIO);
OSStart ();/* begin scheduling */
return 0;
}



Void start_task (void * pdata)
{
OS_ENTER_CRITICAL ();//into the critical region (cannot be interrupted by interrupt)
OSTaskCreate (App1Task, (void *) 0, (OS_STK *) & amp; App1_Task_Stk] [App1Task_StkSize - 1, App1_TASK_PRIO);
//OSTaskCreate (App2Task, (void *) 0, (OS_STK *) & amp; App2_TASK_STK] [App2Task_StkSize - 1, App2_TASK_PRIO);
OSTaskSuspend (START_TASK_PRIO);//hang starting tasks.
OS_EXIT_CRITICAL ();//exit the critical section (can be interrupted interrupt)
}

/* App1Task */
Void App1Task (void * p_arg)
{
P_arg=p_arg;
Unsigned int sysstime=0;
Unsigned int x, y;

While (1)
{
For (x=0; X & lt; 10000; X++)
{
For (y=0; Y & lt; 100000; Y++)
{
P_arg=p_arg;
}
}

Sysstime=OSTimeGet ();//the time of acquisition system
Printf (" system time is: % d \ r \ n ", sysstime);//output time value
Printf (" the number of task scheduling is: % d \ r \ n ", OSCtxSwCtr);//output time value
Printf (" CPU usage is: % d % % \ r \ n ", OSCPUUsage);//output time value
OSTimeDlyHMSM (0, 0, 1, 0);/* delay 1 second task scheduling */
}
}




I'm sure has opened a statistical task
# define OS_TASK_STAT_EN 1 u/* Enable (1) or Disable (0) the statistics task */

UCOS version 2.91

Consult everybody masters is this why?

CodePudding user response:

Circulation is optimized away.

  • Related