Modifying task variable via queue

What rules are relevant to modifying task variables while a task is running? For example, if I have a task to blink an LED and I want to modify the delay length by using the queue to “signal” if that needs to be shortened or lengthened, what would cause the task not to update this variable? Many thanks in advance.

You really should also post the relevant code. Otherwise it’s hard to guess…
However, if your global delay variable can be modified atomically, which is usually the case for CPU-native integers, it has to be specified volatile.

you can not update the delay time externally while the task is in the delay, if that is what your question is about. If you need to shorten an ongoing delay, you can use a timed delay on a queue to which you post when you want the delay to preempt, but you can not extend it. The payload of your queue element can tell the waiting task to resubmit the wait with a new delay period.

But as Hartmut pointed out, your chance to get an answer that satisfies you is dramatically higher if you tell us what you want to accomplish, ideally with code.

In general, your blink function would want to operate on a copy of the delay variable. That way you can avoid the race condition @RAc is concerned with. A delay value is quite likely to be an atomic data type so a volatile BaseType_t ulPublicDelay is a reasonable solution. Just make a local copy of ulPublicDelay as you go through the blink process. If you want to use a queue, just do a queue read with no delay time, If the return value is pdFALSE, then you know the queue was empty and you will not update your delay value from the previous value. If the return value was pdTRUE, then the queue was not empty and you can now use the new value read from the queue.

If the queue is a “command queue” and you post the “blink fast” or “blink slow” command, then your code would just load the appropriate rate values from known constants corresponding to “fast” and “slow”.

These are just some generic techniques, if you post your idea as code, I am sure you will get many suggestions.