/*\r
- FreeRTOS V9.0.1 - Copyright (C) 2017 Real Time Engineers Ltd.\r
- All rights reserved\r
-\r
- VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
-\r
- This file is part of the FreeRTOS distribution.\r
-\r
- FreeRTOS is free software; you can redistribute it and/or modify it under\r
- the terms of the GNU General Public License (version 2) as published by the\r
- Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.\r
-\r
- ***************************************************************************\r
- >>! NOTE: The modification to the GPL is included to allow you to !<<\r
- >>! distribute a combined work that includes FreeRTOS without being !<<\r
- >>! obliged to provide the source code for proprietary components !<<\r
- >>! outside of the FreeRTOS kernel. !<<\r
- ***************************************************************************\r
-\r
- FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
- FOR A PARTICULAR PURPOSE. Full license text is available on the following\r
- link: http://www.freertos.org/a00114.html\r
-\r
- ***************************************************************************\r
- * *\r
- * FreeRTOS provides completely free yet professionally developed, *\r
- * robust, strictly quality controlled, supported, and cross *\r
- * platform software that is more than just the market leader, it *\r
- * is the industry's de facto standard. *\r
- * *\r
- * Help yourself get started quickly while simultaneously helping *\r
- * to support the FreeRTOS project by purchasing a FreeRTOS *\r
- * tutorial book, reference manual, or both: *\r
- * http://www.FreeRTOS.org/Documentation *\r
- * *\r
- ***************************************************************************\r
-\r
- http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading\r
- the FAQ page "My application does not run, what could be wrong?". Have you\r
- defined configASSERT()?\r
-\r
- http://www.FreeRTOS.org/support - In return for receiving this top quality\r
- embedded software for free we request you assist our global community by\r
- participating in the support forum.\r
-\r
- http://www.FreeRTOS.org/training - Investing in training allows your team to\r
- be as productive as possible as early as possible. Now you can receive\r
- FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
- Ltd, and the world's leading authority on the world's leading RTOS.\r
-\r
- http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
- including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
- compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
-\r
- http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
- Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
-\r
- http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
- Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS\r
- licenses offer ticketed support, indemnification and commercial middleware.\r
-\r
- http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
- engineered and independently SIL3 certified version for use in safety and\r
- mission critical applications that require provable dependability.\r
-\r
- 1 tab == 4 spaces!\r
-*/\r
+ * FreeRTOS Kernel V10.0.1\r
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+ * this software and associated documentation files (the "Software"), to deal in\r
+ * the Software without restriction, including without limitation the rights to\r
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
+ * the Software, and to permit persons to whom the Software is furnished to do so,\r
+ * subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included in all\r
+ * copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ *\r
+ * http://www.FreeRTOS.org\r
+ * http://aws.amazon.com/freertos\r
+ *\r
+ * 1 tab == 4 spaces!\r
+ */\r
\r
/* Standard includes. */\r
#include <stdlib.h>\r
#include "FreeRTOS.h"\r
#include "task.h"\r
#include "timers.h"\r
-#include "StackMacros.h"\r
+#include "stack_macros.h"\r
\r
/* Lint e961 and e750 are suppressed as a MISRA exception justified because the\r
MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the\r
/*\r
* Macros used by vListTask to indicate which state a task is in.\r
*/\r
+#define tskRUNNING_CHAR ( 'X' )\r
#define tskBLOCKED_CHAR ( 'B' )\r
#define tskREADY_CHAR ( 'R' )\r
#define tskDELETED_CHAR ( 'D' )\r
#endif /* ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) */\r
/*-----------------------------------------------------------*/\r
\r
-#if( ( portUSING_MPU_WRAPPERS == 1 ) && ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) )\r
+#if( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )\r
\r
BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask )\r
{\r
/* Store the stack location in the TCB. */\r
pxNewTCB->pxStack = pxTaskDefinition->puxStackBuffer;\r
\r
- /* Tasks can be created statically or dynamically, so note\r
- this task had a statically allocated stack in case it is\r
- later deleted. The TCB was allocated dynamically. */\r
- pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_ONLY;\r
+ #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+ {\r
+ /* Tasks can be created statically or dynamically, so note\r
+ this task had a statically allocated stack in case it is\r
+ later deleted. The TCB was allocated dynamically. */\r
+ pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_ONLY;\r
+ }\r
+ #endif\r
\r
prvInitialiseNewTask( pxTaskDefinition->pvTaskCode,\r
pxTaskDefinition->pcName,\r
}\r
else\r
{\r
+ *pxTicksToWait = 0;\r
xReturn = pdTRUE;\r
}\r
}\r
/** THIS IS THE RTOS IDLE TASK - WHICH IS CREATED AUTOMATICALLY WHEN THE\r
SCHEDULER IS STARTED. **/\r
\r
+ /* In case a task that has a secure context deletes itself, in which case\r
+ the idle task is responsible for deleting the task's secure context, if\r
+ any. */\r
+ portTASK_CALLS_SECURE_FUNCTIONS();\r
+\r
for( ;; )\r
{\r
/* See if any tasks have deleted themselves - if so then the idle task\r
\r
#if ( INCLUDE_vTaskDelete == 1 )\r
{\r
- BaseType_t xListIsEmpty;\r
+ TCB_t *pxTCB;\r
\r
- /* ucTasksDeleted is used to prevent vTaskSuspendAll() being called\r
- too often in the idle task. */\r
+ /* uxDeletedTasksWaitingCleanUp is used to prevent taskENTER_CRITICAL()\r
+ being called too often in the idle task. */\r
while( uxDeletedTasksWaitingCleanUp > ( UBaseType_t ) 0U )\r
{\r
- vTaskSuspendAll();\r
+ taskENTER_CRITICAL();\r
{\r
- xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination );\r
+ pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) );\r
+ ( void ) uxListRemove( &( pxTCB->xStateListItem ) );\r
+ --uxCurrentNumberOfTasks;\r
+ --uxDeletedTasksWaitingCleanUp;\r
}\r
- ( void ) xTaskResumeAll();\r
-\r
- if( xListIsEmpty == pdFALSE )\r
- {\r
- TCB_t *pxTCB;\r
-\r
- taskENTER_CRITICAL();\r
- {\r
- pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) );\r
- ( void ) uxListRemove( &( pxTCB->xStateListItem ) );\r
- --uxCurrentNumberOfTasks;\r
- --uxDeletedTasksWaitingCleanUp;\r
- }\r
- taskEXIT_CRITICAL();\r
+ taskEXIT_CRITICAL();\r
\r
- prvDeleteTCB( pxTCB );\r
- }\r
- else\r
- {\r
- mtCOVERAGE_TEST_MARKER();\r
- }\r
+ prvDeleteTCB( pxTCB );\r
}\r
}\r
#endif /* INCLUDE_vTaskDelete */\r
pxTaskStatus->pxStackBase = pxTCB->pxStack;\r
pxTaskStatus->xTaskNumber = pxTCB->uxTCBNumber;\r
\r
- #if ( INCLUDE_vTaskSuspend == 1 )\r
- {\r
- /* If the task is in the suspended list then there is a chance it is\r
- actually just blocked indefinitely - so really it should be reported as\r
- being in the Blocked state. */\r
- if( pxTaskStatus->eCurrentState == eSuspended )\r
- {\r
- vTaskSuspendAll();\r
- {\r
- if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL )\r
- {\r
- pxTaskStatus->eCurrentState = eBlocked;\r
- }\r
- }\r
- ( void ) xTaskResumeAll();\r
- }\r
- }\r
- #endif /* INCLUDE_vTaskSuspend */\r
-\r
#if ( configUSE_MUTEXES == 1 )\r
{\r
pxTaskStatus->uxBasePriority = pxTCB->uxBasePriority;\r
}\r
#endif\r
\r
- /* Obtaining the task state is a little fiddly, so is only done if the value\r
- of eState passed into this function is eInvalid - otherwise the state is\r
- just set to whatever is passed in. */\r
+ /* Obtaining the task state is a little fiddly, so is only done if the\r
+ value of eState passed into this function is eInvalid - otherwise the\r
+ state is just set to whatever is passed in. */\r
if( eState != eInvalid )\r
{\r
- pxTaskStatus->eCurrentState = eState;\r
+ if( pxTCB == pxCurrentTCB )\r
+ {\r
+ pxTaskStatus->eCurrentState = eRunning;\r
+ }\r
+ else\r
+ {\r
+ pxTaskStatus->eCurrentState = eState;\r
+\r
+ #if ( INCLUDE_vTaskSuspend == 1 )\r
+ {\r
+ /* If the task is in the suspended list then there is a\r
+ chance it is actually just blocked indefinitely - so really\r
+ it should be reported as being in the Blocked state. */\r
+ if( eState == eSuspended )\r
+ {\r
+ vTaskSuspendAll();\r
+ {\r
+ if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL )\r
+ {\r
+ pxTaskStatus->eCurrentState = eBlocked;\r
+ }\r
+ }\r
+ ( void ) xTaskResumeAll();\r
+ }\r
+ }\r
+ #endif /* INCLUDE_vTaskSuspend */\r
+ }\r
}\r
else\r
{\r
- pxTaskStatus->eCurrentState = eTaskGetState( xTask );\r
+ pxTaskStatus->eCurrentState = eTaskGetState( pxTCB );\r
}\r
\r
/* Obtaining the stack space takes some time, so the xGetFreeStackSpace\r
{\r
/* Neither the stack nor the TCB were allocated dynamically, so\r
nothing needs to be freed. */\r
- configASSERT( pxTCB->ucStaticallyAllocated == tskSTATICALLY_ALLOCATED_STACK_AND_TCB )\r
+ configASSERT( pxTCB->ucStaticallyAllocated == tskSTATICALLY_ALLOCATED_STACK_AND_TCB );\r
mtCOVERAGE_TEST_MARKER();\r
}\r
}\r
{\r
switch( pxTaskStatusArray[ x ].eCurrentState )\r
{\r
+ case eRunning: cStatus = tskRUNNING_CHAR;\r
+ break;\r
+\r
case eReady: cStatus = tskREADY_CHAR;\r
break;\r
\r