X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=FreeRTOS%2FDemo%2FCommon%2FMinimal%2Fdeath.c;h=aff60e59af6b73ec971ee358874750b9416d31a8;hb=b15dfacb6026af3b0ba697e5753844923b468d2b;hp=d6a9110b700b1aafefd2b08550fd7ae12b4d6a7c;hpb=abf43e0ca4466819c7c77a7bb37d72aa9175e471;p=freertos
diff --git a/FreeRTOS/Demo/Common/Minimal/death.c b/FreeRTOS/Demo/Common/Minimal/death.c
index d6a9110b7..aff60e59a 100644
--- a/FreeRTOS/Demo/Common/Minimal/death.c
+++ b/FreeRTOS/Demo/Common/Minimal/death.c
@@ -1,67 +1,29 @@
/*
- FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
- All rights reserved
-
- VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
-
- ***************************************************************************
- * *
- * FreeRTOS provides completely free yet professionally developed, *
- * robust, strictly quality controlled, supported, and cross *
- * platform software that has become a de facto standard. *
- * *
- * Help yourself get started quickly and support the FreeRTOS *
- * project by purchasing a FreeRTOS tutorial book, reference *
- * manual, or both from: http://www.FreeRTOS.org/Documentation *
- * *
- * Thank you! *
- * *
- ***************************************************************************
-
- This file is part of the FreeRTOS distribution.
-
- FreeRTOS is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License (version 2) as published by the
- Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
-
- >>! NOTE: The modification to the GPL is included to allow you to distribute
- >>! a combined work that includes FreeRTOS without being obliged to provide
- >>! the source code for proprietary components outside of the FreeRTOS
- >>! kernel.
-
- FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. Full license text is available from the following
- link: http://www.freertos.org/a00114.html
-
- 1 tab == 4 spaces!
-
- ***************************************************************************
- * *
- * Having a problem? Start by reading the FAQ "My application does *
- * not run, what could be wrong?" *
- * *
- * http://www.FreeRTOS.org/FAQHelp.html *
- * *
- ***************************************************************************
-
- http://www.FreeRTOS.org - Documentation, books, training, latest versions,
- license and Real Time Engineers Ltd. contact details.
-
- http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
- including FreeRTOS+Trace - an indispensable productivity tool, a DOS
- compatible FAT file system, and our tiny thread aware UDP/IP stack.
-
- http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
- Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
- licenses offer ticketed support, indemnification and middleware.
-
- http://www.SafeRTOS.com - High Integrity Systems also provide a safety
- engineered and independently SIL3 certified version for use in safety and
- mission critical applications that require provable dependability.
-
- 1 tab == 4 spaces!
-*/
+ * FreeRTOS Kernel V10.3.0
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
/**
* Create a single persistent task which periodically dynamically creates another
@@ -82,19 +44,6 @@
*
*/
-/*
-Changes from V3.0.0
- + CreationCount sizes changed from unsigned portBASE_TYPE to
- unsigned short to minimize the risk of overflowing.
-
- + Reset of usLastCreationCount added
-
-Changes from V3.1.0
- + Changed the dummy calculation to use variables of type long, rather than
- float. This allows the file to be used with ports that do not support
- floating point.
-
-*/
#include
@@ -116,67 +65,47 @@ static portTASK_FUNCTION_PROTO( vSuicidalTask, pvParameters );
/* A variable which is incremented every time the dynamic tasks are created. This
is used to check that the task is still running. */
-static volatile unsigned short usCreationCount = 0;
+static volatile uint16_t usCreationCount = 0;
/* Used to store the number of tasks that were originally running so the creator
task can tell if any of the suicidal tasks have failed to die.
*/
-static volatile unsigned portBASE_TYPE uxTasksRunningAtStart = 0;
+static volatile UBaseType_t uxTasksRunningAtStart = 0;
-/* Tasks are deleted by the idle task. Under heavy load the idle task might
-not get much processing time, so it would be legitimate for several tasks to
-remain undeleted for a short period. */
-static const unsigned portBASE_TYPE uxMaxNumberOfExtraTasksRunning = 3;
+/* When a task deletes itself, it stack and TCB are cleaned up by the Idle task.
+Under heavy load the idle task might not get much processing time, so it would
+be legitimate for several tasks to remain undeleted for a short period. There
+may also be a few other unexpected tasks if, for example, the tasks that test
+static allocation are also being used. */
+static const UBaseType_t uxMaxNumberOfExtraTasksRunning = 3;
/* Used to store a handle to the task that should be killed by a suicidal task,
before it kills itself. */
-xTaskHandle xCreatedTask;
+TaskHandle_t xCreatedTask;
/*-----------------------------------------------------------*/
-void vCreateSuicidalTasks( unsigned portBASE_TYPE uxPriority )
+void vCreateSuicidalTasks( UBaseType_t uxPriority )
{
-unsigned portBASE_TYPE *puxPriority;
-
- /* Create the Creator tasks - passing in as a parameter the priority at which
- the suicidal tasks should be created. */
- puxPriority = ( unsigned portBASE_TYPE * ) pvPortMalloc( sizeof( unsigned portBASE_TYPE ) );
- *puxPriority = uxPriority;
-
- xTaskCreate( vCreateTasks, ( signed char * ) "CREATOR", deathSTACK_SIZE, ( void * ) puxPriority, uxPriority, NULL );
-
- /* Record the number of tasks that are running now so we know if any of the
- suicidal tasks have failed to be killed. */
- uxTasksRunningAtStart = ( unsigned portBASE_TYPE ) uxTaskGetNumberOfTasks();
-
- /* FreeRTOS.org versions before V3.0 started the idle-task as the very
- first task. The idle task was then already included in uxTasksRunningAtStart.
- From FreeRTOS V3.0 on, the idle task is started when the scheduler is
- started. Therefore the idle task is not yet accounted for. We correct
- this by increasing uxTasksRunningAtStart by 1. */
- uxTasksRunningAtStart++;
-
- /* From FreeRTOS version 7.0.0 can optionally create a timer service task.
- If this is done, then uxTasksRunningAtStart needs incrementing again as that
- too is created when the scheduler is started. */
- #if configUSE_TIMERS == 1
- uxTasksRunningAtStart++;
- #endif
+ xTaskCreate( vCreateTasks, "CREATOR", deathSTACK_SIZE, ( void * ) NULL, uxPriority, NULL );
}
/*-----------------------------------------------------------*/
-
+
static portTASK_FUNCTION( vSuicidalTask, pvParameters )
{
volatile long l1, l2;
-xTaskHandle xTaskToKill;
-const portTickType xDelay = ( portTickType ) 200 / portTICK_RATE_MS;
+TaskHandle_t xTaskToKill;
+const TickType_t xDelay = pdMS_TO_TICKS( ( TickType_t ) 200 );
+
+ /* Test deletion of a task's secure context, if any. */
+ portALLOCATE_SECURE_CONTEXT( configMINIMAL_SECURE_STACK_SIZE );
if( pvParameters != NULL )
{
/* This task is periodically created four times. Two created tasks are
passed a handle to the other task so it can kill it before killing itself.
The other task is passed in null. */
- xTaskToKill = *( xTaskHandle* )pvParameters;
+ xTaskToKill = *( TaskHandle_t* )pvParameters;
}
else
{
@@ -194,7 +123,7 @@ const portTickType xDelay = ( portTickType ) 200 / portTICK_RATE_MS;
if( xTaskToKill != NULL )
{
/* Make sure the other task has a go before we delete it. */
- vTaskDelay( ( portTickType ) 0 );
+ vTaskDelay( ( TickType_t ) 0 );
/* Kill the other task that was created by vCreateTasks(). */
vTaskDelete( xTaskToKill );
@@ -208,11 +137,18 @@ const portTickType xDelay = ( portTickType ) 200 / portTICK_RATE_MS;
static portTASK_FUNCTION( vCreateTasks, pvParameters )
{
-const portTickType xDelay = ( portTickType ) 1000 / portTICK_RATE_MS;
-unsigned portBASE_TYPE uxPriority;
+const TickType_t xDelay = pdMS_TO_TICKS( ( TickType_t ) 1000 );
+UBaseType_t uxPriority;
- uxPriority = *( unsigned portBASE_TYPE * ) pvParameters;
- vPortFree( pvParameters );
+ /* Remove compiler warning about unused parameter. */
+ ( void ) pvParameters;
+
+ /* Delay at the start to ensure tasks created by other demos have been
+ created before storing the current number of tasks. */
+ vTaskDelay( xDelay );
+ uxTasksRunningAtStart = ( UBaseType_t ) uxTaskGetNumberOfTasks();
+
+ uxPriority = uxTaskPriorityGet( NULL );
for( ;; )
{
@@ -221,8 +157,8 @@ unsigned portBASE_TYPE uxPriority;
xCreatedTask = NULL;
- xTaskCreate( vSuicidalTask, ( signed char * ) "SUICID1", configMINIMAL_STACK_SIZE, NULL, uxPriority, &xCreatedTask );
- xTaskCreate( vSuicidalTask, ( signed char * ) "SUICID2", configMINIMAL_STACK_SIZE, &xCreatedTask, uxPriority, NULL );
+ xTaskCreate( vSuicidalTask, "SUICID1", configMINIMAL_STACK_SIZE, NULL, uxPriority, &xCreatedTask );
+ xTaskCreate( vSuicidalTask, "SUICID2", configMINIMAL_STACK_SIZE, &xCreatedTask, uxPriority, NULL );
++usCreationCount;
}
@@ -231,11 +167,11 @@ unsigned portBASE_TYPE uxPriority;
/* This is called to check that the creator task is still running and that there
are not any more than four extra tasks. */
-portBASE_TYPE xIsCreateTaskStillRunning( void )
+BaseType_t xIsCreateTaskStillRunning( void )
{
-static unsigned short usLastCreationCount = 0xfff;
-portBASE_TYPE xReturn = pdTRUE;
-static unsigned portBASE_TYPE uxTasksRunningNow;
+static uint16_t usLastCreationCount = 0xfff;
+BaseType_t xReturn = pdTRUE;
+static UBaseType_t uxTasksRunningNow;
if( usLastCreationCount == usCreationCount )
{
@@ -245,8 +181,8 @@ static unsigned portBASE_TYPE uxTasksRunningNow;
{
usLastCreationCount = usCreationCount;
}
-
- uxTasksRunningNow = ( unsigned portBASE_TYPE ) uxTaskGetNumberOfTasks();
+
+ uxTasksRunningNow = ( UBaseType_t ) uxTaskGetNumberOfTasks();
if( uxTasksRunningNow < uxTasksRunningAtStart )
{