#include <stdlib.h>
#include "FreeRTOS.h"
#include "task.h"
#include "death.h"
Go to the source code of this file.
Defines | |
#define | deathSTACK_SIZE ( configMINIMAL_STACK_SIZE + 60 ) |
Functions | |
static | portTASK_FUNCTION (vCreateTasks, pvParameters) |
static | portTASK_FUNCTION (vSuicidalTask, pvParameters) |
static | portTASK_FUNCTION_PROTO (vSuicidalTask, pvParameters) |
static | portTASK_FUNCTION_PROTO (vCreateTasks, pvParameters) |
void | vCreateSuicidalTasks (unsigned portBASE_TYPE uxPriority) |
portBASE_TYPE | xIsCreateTaskStillRunning (void) |
Variables | |
static volatile unsigned short | usCreationCount = 0 |
static const unsigned portBASE_TYPE | uxMaxNumberOfExtraTasksRunning = 2 |
static volatile unsigned portBASE_TYPE | uxTasksRunningAtStart = 0 |
xTaskHandle | xCreatedTask |
#define deathSTACK_SIZE ( configMINIMAL_STACK_SIZE + 60 ) |
static portTASK_FUNCTION | ( | vCreateTasks | , | |
pvParameters | ||||
) | [static] |
Definition at line 190 of file death.c.
References configMINIMAL_STACK_SIZE, portBASE_TYPE, portTICK_RATE_MS, usCreationCount, vPortFree(), vTaskDelay(), xCreatedTask, and xTaskCreate.
00191 { 00192 const portTickType xDelay = ( portTickType ) 1000 / portTICK_RATE_MS; 00193 unsigned portBASE_TYPE uxPriority; 00194 00195 uxPriority = *( unsigned portBASE_TYPE * ) pvParameters; 00196 vPortFree( pvParameters ); 00197 00198 for( ;; ) 00199 { 00200 /* Just loop round, delaying then creating the four suicidal tasks. */ 00201 vTaskDelay( xDelay ); 00202 00203 xCreatedTask = NULL; 00204 00205 xTaskCreate( vSuicidalTask, ( signed char * ) "SUICID1", configMINIMAL_STACK_SIZE, NULL, uxPriority, &xCreatedTask ); 00206 xTaskCreate( vSuicidalTask, ( signed char * ) "SUICID2", configMINIMAL_STACK_SIZE, &xCreatedTask, uxPriority, NULL ); 00207 00208 ++usCreationCount; 00209 } 00210 }
static portTASK_FUNCTION | ( | vSuicidalTask | , | |
pvParameters | ||||
) | [static] |
Definition at line 149 of file death.c.
References portTICK_RATE_MS, vTaskDelay(), and vTaskDelete().
00150 { 00151 volatile long l1, l2; 00152 xTaskHandle xTaskToKill; 00153 const portTickType xDelay = ( portTickType ) 200 / portTICK_RATE_MS; 00154 00155 if( pvParameters != NULL ) 00156 { 00157 /* This task is periodically created four times. Two created tasks are 00158 passed a handle to the other task so it can kill it before killing itself. 00159 The other task is passed in null. */ 00160 xTaskToKill = *( xTaskHandle* )pvParameters; 00161 } 00162 else 00163 { 00164 xTaskToKill = NULL; 00165 } 00166 00167 for( ;; ) 00168 { 00169 /* Do something random just to use some stack and registers. */ 00170 l1 = 2; 00171 l2 = 89; 00172 l2 *= l1; 00173 vTaskDelay( xDelay ); 00174 00175 if( xTaskToKill != NULL ) 00176 { 00177 /* Make sure the other task has a go before we delete it. */ 00178 vTaskDelay( ( portTickType ) 0 ); 00179 00180 /* Kill the other task that was created by vCreateTasks(). */ 00181 vTaskDelete( xTaskToKill ); 00182 00183 /* Kill ourselves. */ 00184 vTaskDelete( NULL ); 00185 } 00186 } 00187 }/*lint !e818 !e550 Function prototype must be as per standard for task functions. */
static portTASK_FUNCTION_PROTO | ( | vSuicidalTask | , | |
pvParameters | ||||
) | [static] |
static portTASK_FUNCTION_PROTO | ( | vCreateTasks | , | |
pvParameters | ||||
) | [static] |
void vCreateSuicidalTasks | ( | unsigned portBASE_TYPE | uxPriority | ) |
Definition at line 125 of file death.c.
References deathSTACK_SIZE, portBASE_TYPE, pvPortMalloc(), uxTaskGetNumberOfTasks(), uxTasksRunningAtStart, and xTaskCreate.
Referenced by vErrorChecks().
00126 { 00127 unsigned portBASE_TYPE *puxPriority; 00128 00129 /* Create the Creator tasks - passing in as a parameter the priority at which 00130 the suicidal tasks should be created. */ 00131 puxPriority = ( unsigned portBASE_TYPE * ) pvPortMalloc( sizeof( unsigned portBASE_TYPE ) ); 00132 *puxPriority = uxPriority; 00133 00134 xTaskCreate( vCreateTasks, ( signed char * ) "CREATOR", deathSTACK_SIZE, ( void * ) puxPriority, uxPriority, NULL ); 00135 00136 /* Record the number of tasks that are running now so we know if any of the 00137 suicidal tasks have failed to be killed. */ 00138 uxTasksRunningAtStart = ( unsigned portBASE_TYPE ) uxTaskGetNumberOfTasks(); 00139 00140 /* FreeRTOS.org versions before V3.0 started the idle-task as the very 00141 first task. The idle task was then already included in uxTasksRunningAtStart. 00142 From FreeRTOS V3.0 on, the idle task is started when the scheduler is 00143 started. Therefore the idle task is not yet accounted for. We correct 00144 this by increasing uxTasksRunningAtStart by 1. */ 00145 uxTasksRunningAtStart++; 00146 }
portBASE_TYPE xIsCreateTaskStillRunning | ( | void | ) |
Definition at line 215 of file death.c.
References pdFALSE, pdTRUE, portBASE_TYPE, usCreationCount, uxMaxNumberOfExtraTasksRunning, uxTaskGetNumberOfTasks(), and uxTasksRunningAtStart.
Referenced by prvCheckOtherTasksAreStillRunning().
00216 { 00217 static unsigned short usLastCreationCount = 0xfff; 00218 portBASE_TYPE xReturn = pdTRUE; 00219 static unsigned portBASE_TYPE uxTasksRunningNow; 00220 00221 if( usLastCreationCount == usCreationCount ) 00222 { 00223 xReturn = pdFALSE; 00224 } 00225 else 00226 { 00227 usLastCreationCount = usCreationCount; 00228 } 00229 00230 uxTasksRunningNow = ( unsigned portBASE_TYPE ) uxTaskGetNumberOfTasks(); 00231 00232 if( uxTasksRunningNow < uxTasksRunningAtStart ) 00233 { 00234 xReturn = pdFALSE; 00235 } 00236 else if( ( uxTasksRunningNow - uxTasksRunningAtStart ) > uxMaxNumberOfExtraTasksRunning ) 00237 { 00238 xReturn = pdFALSE; 00239 } 00240 else 00241 { 00242 /* Everything is okay. */ 00243 } 00244 00245 return xReturn; 00246 }
volatile unsigned short usCreationCount = 0 [static] |
Definition at line 107 of file death.c.
Referenced by portTASK_FUNCTION(), and xIsCreateTaskStillRunning().
const unsigned portBASE_TYPE uxMaxNumberOfExtraTasksRunning = 2 [static] |
volatile unsigned portBASE_TYPE uxTasksRunningAtStart = 0 [static] |
Definition at line 112 of file death.c.
Referenced by vCreateSuicidalTasks(), and xIsCreateTaskStillRunning().