Home > other >  Mu C/OS - II ucos task after delete itself, in other tasks don't run, how be to return a respon
Mu C/OS - II ucos task after delete itself, in other tasks don't run, how be to return a respon

Time:09-27

I find on the net of the mu C/OS - II transplantation on VS2015 revised on the basis of the application program
Source code for the following
# 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);


//App2 task
//set the task priority
# define App2_TASK_PRIO 6
//set the task stack size
# define App2_STK_SIZE 64
//task stack
OS_STK App2_TASK_STK [App2_STK_SIZE];
//task function
Void App2Task (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 char I=0;

While (1)
{
Printf (" App1Task: I'm a task a \ r \ n ");
Printf (" App1Task: I hang up! \r\n");
OSTaskDel (OS_PRIO_SELF);//delete the task itself
}
}
/* App2Task */
Void App2Task (void * p_arg)
{
P_arg=p_arg;
While (1)
{
If (OSTaskDelReq (OS_PRIO_SELF)==OS_ERR_TASK_DEL_REQ)
{
Printf (" App2Task: I am a task 2! \r\n");
Printf (" App2Task: I have deleted myself! \r\n");
OSTaskDel (OS_PRIO_SELF);//delete the task itself
}
The else
{
Printf (" who are you? \n");
OSTimeDlyHMSM (0, 0, 1, 0); Task scheduling *//*
}
}
}
Results have been stuck in here


Task APPTask1 deleted after, why task APPTask2 also not output? Task APPTask1 didn't delete it!!
The normal below should have been printed "who are you"!! The result is dead card

This is I find on the net of the mu COS transplanted into VS2015 revised on the basis of the program,,,,,,, is there?
Online, such as the great god answer,,,,
  • Related