Currently we are learning how to program AVR micro-controllers (Ansi C89 standard only). Part of the included drivers is a header that deals with scheduling ie running tasks at different rates. My question is to do with a quote from the documentation:
"Each task must maintain its own state, by using static local variables."
What does that mean really? They seem to pass a void*
to the function to maintain the state but then do not use it?
Looking at the code in the file I gather this is what they mean:
{.func = led_flash_task, .period = TASK_RATE / LED_TASK_RATE, .data = 0}
/* Last term the pointer term */
There is a function that runs with the above parameters in an array however, it only acts as a scheduler. Then the function led_flash_task
is
static void led_flash_task (__unused__ void *data)
{
static uint8_t state = 0;
led_set (LED1, state); /*Not reall important what this task is */
state = !state; /*Turn the LED on or off */
}
And from the header
#define __unused__ __attribute__ ((unused))
And the passing of the void *data
is meant to maintain the state of the task? What is meant by this?
Thank-you for your help