nobody wrote on Tuesday, April 17, 2007:
Why does it suspend all tasks and then resume them?
Isn’t it possible wait a fixed period without suspend the tasks?
I created 2 tasks that switch on\off leds. Each task has its own leds. In one task I repalce the vTaskDelayUntil with for cycles simulated a waiting period.
To be sure under the for (always) { } I added a CRITICAL REGION.
-----------------------
static portTASK_FUNCTION( vLEDFlashTask1, pvParameters )
{
portTickType xFlashRate, xLastFlashTime;
unsigned portBASE_TYPE uxLED;
int i;
int max;
max=0x7FFFFFF;
/* The parameters are not used. */
( void ) pvParameters;
uxLED=1;
xFlashRate = ledFLASH_RATE_BASE + ( ledFLASH_RATE_BASE * ( portTickType ) uxLED );
xFlashRate /= portTICK_RATE_MS;
/* We will turn the LED on and off again in the delay period, so each
delay is only half the total period. */
xFlashRate /= ( portTickType ) 1 ;
/* We need to initialise xLastFlashTime prior to the first call to
vTaskDelayUntil(). */
xLastFlashTime = xTaskGetTickCount();
for(;
{
taskENTER_CRITICAL();
{
/* Delay for half the flash period then turn the LED on. */
vTaskDelayUntil( &xLastFlashTime, xFlashRate );
for (i=0;i<max;i++){
i=i;
}
vParTestToggleLED( uxLED-1 );
/* Delay for half the flash period then turn the LED off. */
// vTaskDelayUntil( &xLastFlashTime, xFlashRate );
for (i=0;i<max;i++){
i=i;
}
vParTestToggleLED( uxLED-1 );
/* Delay for half the flash period then turn the LED on. */
// vTaskDelayUntil( &xLastFlashTime, xFlashRate );
for (i=0;i<max;i++){
i=i;
}
vParTestToggleLED( uxLED );
/* Delay for half the flash period then turn the LED off. */
// vTaskDelayUntil( &xLastFlashTime, xFlashRate );
for (i=0;i<max;i++){
i=i;
}
vParTestToggleLED( uxLED );
}
taskEXIT_CRITICAL();
}
}
------------------------
When I run, leds of this task are always lighting fast. It not waits as the for always cycle says. Why?