willywortel wrote on Saturday, November 15, 2008:
Because i want to run multiple threats that oversize the heap, i want to kill an application if not needed.
I tried a two simple tasks; one that flashes the LED’s continuously on the PIC32 Explorer16 board. This is the task that should be killed and created.
Then i created another task, with the same priority, that gives me information on the Explorer16 display. Also in this display task there is a simple counter that every time it reaches 3 it will kill or start the LED task. This display task has a task delay of 1000mS, so every 3 sec. the LED application should be started or killed.
It seems that the function vTaskDelete somehow ends up in a endless loop. I noticed this because when I call it from the display task, the display task will freeze permanently after 21 sec. running time. Till 21 sec. it does it job; every 3 sec. it will kill or start the LED task.
To prevent the display task from freezing (because then i cannot see any variables or use full info anymore on the display), i created a function that only gives the LED task a "true" variable so when the LED task gets executed it will read the "true" variable and thus killing itself.
There are no other things running. The tasks above are the only ones.
Below is the code of the LED task:
-------------------------------------------
/* Standard includes. */
#include <stdio.h>
/* Scheduler includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
char Switch;
char KillApp;
xTaskHandle xHandle_led;
void vLEDs(void *pvParameters)
{
// initialisatie
mJTAGPortEnable( 0 );
TRISA = 0;
xHandle_led = 0;
while(1){
if(Switch){
PORTA = 0;
Switch = 0;
}
else
{
PORTA = 0xFFFF;
Switch = 1;
}
if (KillApp == 1)
{
PORTA = 0;
KillApp = 0;
vTaskDelete( NULL );
}
vTaskDelay( 20 );
// Taak code
}
}
void vTaskCreateKnipperLed(void)
{
xTaskCreate( vLEDs, "LED",configMINIMAL_STACK_SIZE * 2, NULL, tskIDLE_PRIORITY, &xHandle_led );
}
void vTaskDeleteKnipperLed(void)
{
KillApp = 1;
}