/* Delay until it is time to execute again. */\r
vTaskDelay( mainCHECK_PERIOD );\r
\r
- /* Delete the dynamically created task. */\r
- if( xCreatedTask != mainNO_TASK )\r
- {\r
- vTaskDelete( xCreatedTask );\r
- }\r
-\r
/* Perform a bit of 32bit maths to ensure the registers used by the\r
integer tasks get some exercise. The result here is not important -\r
see the demo application documentation for more info. */\r
/* Toggle the LED if everything is okay. */\r
vParTestToggleLED( mainCHECK_TASK_LED );\r
}\r
+\r
+ /* Delete the dynamically created task. */\r
+ if( xCreatedTask != mainNO_TASK )\r
+ {\r
+ vTaskDelete( xCreatedTask );\r
+ }\r
}\r
}\r
/*-----------------------------------------------------------*/\r
\r
/**\r
* Create a single persistent task which periodically dynamically creates another\r
- * four tasks. The original task is called the creator task, the four tasks it\r
+ * two tasks. The original task is called the creator task, the two tasks it\r
* creates are called suicidal tasks.\r
*\r
- * Two of the created suicidal tasks kill one other suicidal task before killing\r
- * themselves - leaving just the original task remaining.\r
+ * One of the created suicidal tasks kill one other suicidal task before killing\r
+ * itself - leaving just the original task remaining.\r
*\r
* The creator task must be spawned after all of the other demo application tasks\r
* as it keeps a check on the number of tasks under the scheduler control. The\r
/* Demo program include files. */\r
#include "death.h"\r
\r
-#define deathSTACK_SIZE ( configMINIMAL_STACK_SIZE + 24 )\r
+#define deathSTACK_SIZE ( configMINIMAL_STACK_SIZE + 60 )\r
\r
/* The task originally created which is responsible for periodically dynamically\r
creating another four tasks. */\r
/* Tasks are deleted by the idle task. Under heavy load the idle task might\r
not get much processing time, so it would be legitimate for several tasks to\r
remain undeleted for a short period. */\r
-static const unsigned portBASE_TYPE uxMaxNumberOfExtraTasksRunning = 4;\r
+static const unsigned portBASE_TYPE uxMaxNumberOfExtraTasksRunning = 2;\r
\r
-/* Used to store a handle to the tasks that should be killed by a suicidal task,\r
+/* Used to store a handle to the task that should be killed by a suicidal task,\r
before it kills itself. */\r
-xTaskHandle xCreatedTask1, xCreatedTask2;\r
+xTaskHandle xCreatedTask;\r
\r
/*-----------------------------------------------------------*/\r
\r
{\r
/* Make sure the other task has a go before we delete it. */\r
vTaskDelay( ( portTickType ) 0 );\r
+\r
/* Kill the other task that was created by vCreateTasks(). */\r
- if( xTaskToKill != NULL )\r
- {\r
- vTaskDelete( xTaskToKill );\r
- }\r
+ vTaskDelete( xTaskToKill );\r
+\r
/* Kill ourselves. */\r
vTaskDelete( NULL );\r
}\r
/* Just loop round, delaying then creating the four suicidal tasks. */\r
vTaskDelay( xDelay );\r
\r
- xCreatedTask1 = NULL;\r
- xCreatedTask2 = NULL;\r
-\r
- xTaskCreate( vSuicidalTask, ( signed portCHAR * ) "SUICID1", deathSTACK_SIZE, NULL, uxPriority, &xCreatedTask1 );\r
- xTaskCreate( vSuicidalTask, ( signed portCHAR * ) "SUICID2", deathSTACK_SIZE, &xCreatedTask1, uxPriority, NULL );\r
+ xCreatedTask = NULL;\r
\r
- xTaskCreate( vSuicidalTask, ( signed portCHAR * ) "SUICID1", deathSTACK_SIZE, NULL, uxPriority, &xCreatedTask2 );\r
- xTaskCreate( vSuicidalTask, ( signed portCHAR * ) "SUICID2", deathSTACK_SIZE, &xCreatedTask2, uxPriority, NULL );\r
+ xTaskCreate( vSuicidalTask, ( signed portCHAR * ) "SUICID1", configMINIMAL_STACK_SIZE, NULL, uxPriority, &xCreatedTask );\r
+ xTaskCreate( vSuicidalTask, ( signed portCHAR * ) "SUICID2", configMINIMAL_STACK_SIZE, &xCreatedTask, uxPriority, NULL );\r
\r
++usCreationCount;\r
}\r