If I need guaranteed at least 2 ticks delay should I use
vTaskDelay( 2 ) or
vTaskDelay( 3 ) ?
vTaskDelay(3) means 3 tick interrupts from the time the function is called. The function will be called part way through a time slice so the first tick interrupt will come after a fraction of a time slice, the second one complete time slice later, and the third another complete time slice after that. So 3 is your answer because it means two complete time slices plus whatever fraction of a time slice is left between when the function is called and the next tick interrupt.
That's exactly what I was asking for.
Now another question.
My task blocks on
rc = xQueueReceive( xQueue, data, xTicksToWait );
Queue is updated from UART IRQ for example.
If xTicksToWait expires but due to low priority task is not executed for
some time. And during this time IRQ executed and Queue updated.
What would xQueueReceive return in this case?
In other words who has a higher precedence expiration, Queue update of
first occurred between two?
1) A task is blocked on a queue.
2) The task unblocked because there is a time out, but because of its priority it does not run.
3) An interrupt writes to the queue
4) The task does get some CPU time after the interrupt has written to the queue
The xQueueReceive() function will return pdPASS and the item that was written to the queue between the task unblocking and the task actually running.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.