7 Queues Flashcards
What is a Queue?
A queue is an efficient way to transferring data between tasks or interrupt handlers and tasks.
Where is a queue used?
A queue is used for task-tot-task, task-to-interrupt handler, or interrupt handler-to- task communication.
How many of fixed-size data items does a queue store?
A finite number of data items can be stored in a queue.
A queue is also known as ‘FIFO’ what does FIFO stand for?
FIFO stands first in first out, meaning whatever is at the front (head) of the queue gets out (read) first.
Explain the difference between Queue by Copy and Queue by Reference?
Queue by copy- Sends a copy of the data byte by byte. So that both that sender and receiver have a copy of the data.
Queue by reference – Sends a pointer of the data. Used for large data items.
What are the Advantages to Queue by Copy?
Both the sender and receiver have a copy of the data so even if the sender changes or deletes the data after it’s sent the receiver still has a copy.
Can be reused.
A function can send a stack variable to a queue.
Can transfer directly without allocating a buffer.
How to create a queue?
QueueHandle_t timeQueue=NULL;
timeQueue=xQueueCreate(5, sizeof(uint8_t));
vQueueAddToRegistry(timeQueue, “Time Queue”)
What options are there to write to a queue?
xQueueSend()
xQueueSendToBack()
xQueueSendToFront()
How to write and read from a queue?
xQueueSend()
And
xQueueReceive()
How would a queue now where the data is coming from if it is receiving from multiple sources?
Add an Id data field in a structure.
Where is Queue by Reference useful?
When sending large data that would take up a lot of memory if it was to be copied byte by byte.
What must you consider when using queue by reference?
Communication issues, such as if the send deletes or changes the data while to receive is reading it.