이번 시간에는 TaskState에 대해 받아오는 것을 해본다.
https://www.youtube.com/watch?v=hh8huHGpYLA
void myTask1(void *pvParameters)
{
TickType_t xDelay = pdMS_TO_TICKS(1000);
TickType_t myLastUnblock;
myLastUnblock = xTaskGetTickCount();
//char* text = "Task1\r\n";
//char* text = pcTaskGetName(myTask1Handle);
char* text = "Task1";
int count = 0;
vTaskSuspend(myTask1Handle);
for(;;)
{
vTaskDelayUntil( &myLastUnblock, xDelay );
count ++;
}
}
void myTask2(void *pvParameters)
{
TickType_t xDelay = pdMS_TO_TICKS(1000);
TickType_t myLastUnblock;
myLastUnblock = xTaskGetTickCount();
for(;;)
{
eTaskState myState;
myState = eTaskGetState(myTask1Handle);
printf("the state of task 1 is %d\r\n", myState)
myState = eTaskGetState(myTask2Handle);
printf("the state of task 2 is %d\r\n", myState)
vTaskDelayUntil( &myLastUnblock, xDelay );
}
}
를 완료하면 Task2 에서 Task1 과 Task2 의 상태를 알려준다.
0 : Running , 1 : Ready , 2 : Blocked , 3 : Suspended , 4 : Deleted
char myTaskList[300];
void myTask1(void *pvParameters)
{
TickType_t xDelay = pdMS_TO_TICKS(1000);
TickType_t myLastUnblock;
myLastUnblock = xTaskGetTickCount();
char* text = "Task1";
int count = 0;
vTaskSuspend(myTask1Handle);
for(;;)
{
vTaskDelayUntil( &myLastUnblock, xDelay );
count ++;
}
}
void myTask2(void *pvParameters)
{
TickType_t xDelay = pdMS_TO_TICKS(1000);
TickType_t myLastUnblock;
myLastUnblock = xTaskGetTickCount();
for(;;)
{
vTaskList(myTaskList);
printf("%s\r\n", myTaskList);
vTaskDelayUntil( &myLastUnblock, xDelay );
}
}
다음은 vTaskList() 이다. 이를 출력하면
이렇게 프린트 된다. X 는 Running R은 Ready B는 Blocked S는 Suspend B는 Blocked 이다.
3번째 열은 priority 4번째 열은 Stack Size 5번째 열은 실행될 Serial order 이다.
char myTaskList[300];
void myTask1(void *pvParameters)
{
TickType_t xDelay = pdMS_TO_TICKS(1000);
TickType_t myLastUnblock;
myLastUnblock = xTaskGetTickCount();
char* text = "Task1";
int count = 0;
vTaskSuspend(myTask1Handle);
for(;;)
{
vTaskDelayUntil( &myLastUnblock, xDelay );
count ++;
}
}
void myTask2(void *pvParameters)
{
TickType_t xDelay = pdMS_TO_TICKS(1000);
TickType_t myLastUnblock;
myLastUnblock = xTaskGetTickCount();
for(;;)
{
vTaskList(myTaskList);
printf("The total no of tasks running: %d\r\n", uxTaskGetNumberOfTasks());
//존재하는 Task 수
printf("The total tick : %d\r\n", xTaskGetTickCount());
//소요되는 Total Tick
vTaskDelayUntil( &myLastUnblock, xDelay );
}
}
'FreeRTOS > FreeRTOS 기본 학습' 카테고리의 다른 글
10 FreeRTOS Tutorial: Queues part2 (0) | 2019.06.26 |
---|---|
09 FreeRTOS Tutorial: Queues part1 (0) | 2019.06.21 |
07 FreeRTOS Tutorial: Task Utilities part1 (0) | 2019.06.21 |
06 FreeRTOS Tutorial: Handling Interrupt (0) | 2019.06.20 |
STM32F4 Discovery board - Keil 5 IDE with CubeMX: Tutorial 8 UART - Updated Dec 2017 (0) | 2019.06.10 |