/* Standard includes. */ #include /* Kernel includes. */ #include #include "task.h" #include "queue.h" /* Standard demo includes. */ #include "BlockQ.h" #include "integer.h" #include "semtest.h" #include "PollQ.h" #include "GenQTest.h" #include "QPeek.h" #include "recmutex.h" #include "flop.h" /* Priorities at which the tasks are created. */ #define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 1 ) #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 ) #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 ) #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) #define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) #define mainuIP_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 ) #define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY ) #define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY ) #define mainFLOP_TASK_PRIORITY ( tskIDLE_PRIORITY ) /* Task function prototypes. */ static void prvCheckTask( void *pvParameters ); static void vTask1( void *pvParameters ); static void vTask2( void *pvParameters ); static void vTask3( void *pvParameters ); static void vTask4( void *pvParameters ); xQueueHandle xQueue; xTaskHandle xTask1Handle,xTask2Handle,xTask3Handle,xTask4Handle,xTask5Handle; int main( void ) { portBASE_TYPE xStatus; printf( "%s : %s\n","main","xTaskCreate(vTask1,Task1,configMINIMAL_STACK_SIZE,NULL,1,&xTask1Handle)" ); xTaskCreate(vTask1,"Task1",configMINIMAL_STACK_SIZE,NULL,1,&xTask1Handle); printf( "%s : %s\n","main","xTaskCreate(vTask2,Task2,configMINIMAL_STACK_SIZE,NULL,2,&xTask2Handle)" ); xTaskCreate(vTask2,"Task2",configMINIMAL_STACK_SIZE,NULL,2,&xTask2Handle); printf( "%s : %s\n","main","xTaskCreate(vTask3,Task3,configMINIMAL_STACK_SIZE,NULL,1,&xTask3Handle)" ); xTaskCreate(vTask3,"Task3",configMINIMAL_STACK_SIZE,NULL,1,&xTask3Handle); printf( "%s : %s\n","main","vTaskStartScheduler()" ); vTaskStartScheduler(); /* Should never get here unless there was not enough heap space to create the idle and other system tasks. */ return 0; } /*-----------------------------------------------------------*/ static void vTask1( void *pvParameters )//priority 4 { portBASE_TYPE xStatus; long data; /* Just to remove compiler warning. */ ( void ) pvParameters; printf( "%s : %s\n","Task1","xStatus = xQueueReceive(xQueue,&lDataLocal,portMAX_DELAY)"); xStatus = xQueueReceive(xQueue,&data,portMAX_DELAY); printf( "%s : %s\n","Task1","vTaskDelete(xTask1Handle)"); vTaskDelete(xTask1Handle); } /*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/ static void vTask2( void *pvParameters )//priority 3 { portBASE_TYPE xStatus; long data; /* Just to remove compiler warning. */ ( void ) pvParameters; printf( "%s : %s\n","Task2","xQueue = xQueueCreate( 1,sizeof (long) )"); xQueue = xQueueCreate( 1,sizeof (long) ); printf( "%s : %s\n","Task2","xStatus = xQueueReceive(xQueue,&data,portMAX_DELAY)"); xStatus = xQueueReceive(xQueue,&data,portMAX_DELAY); /* printf( "%s : %s\n","Task2","xStatus = xQueueSendToBack(xQueue,&data,0)"); printf( "%s\n","*PRIORITY VIOLATION*"); xStatus = xQueueSendToBack(xQueue,&data,0); */ printf( "%s : %s\n","Task2","vTaskDelete(xTask2Handle)"); vTaskDelete(xTask2Handle); } /*-----------------------------------------------------------*/ static void vTask3( void *pvParameters )//priority 2 (initial, but later changed to 5 by Task4) { portBASE_TYPE xStatus; long data = 10; /* Just to remove compiler warning. */ ( void ) pvParameters; printf( "%s : %s\n","Task3","vTaskPrioritySet(xTask1Handle,4)"); vTaskPrioritySet(xTask1Handle,4); printf( "%s : %s\n","Task3","xStatus = xQueueSendToBack(xQueue,&data,0)"); xStatus = xQueueSendToBack(xQueue,&data,0); printf( "%s : %s\n","Task3","vTaskDelete(xTask3Handle)"); vTaskDelete(xTask3Handle); } /*-----------------------------------------------------------*/ void vApplicationIdleHook( void ) { const unsigned long ulMSToSleep = 5; /* Sleep to reduce CPU load, but don't sleep indefinitely in case there are tasks waiting to be terminated by the idle task. */ Sleep( ulMSToSleep ); } /*-----------------------------------------------------------*/ void vApplicationMallocFailedHook( void ) { /* Can be implemented if required, but probably not required in this environment and running this demo. */ } /*-----------------------------------------------------------*/ void vApplicationStackOverflowHook( void ) { /* Can be implemented if required, but not required in this environment and running this demo. */ }