Embedded Systems & Firmware

In an RTOS, what is the advantage of using a queue (message queue) to pass data from a sensor-reading task to a display task?

  1. AData passing through a queue is encrypted automatically
  2. BThe receiver can sleep until data arrives, and differences in speed between sender and receiver are absorbed by the queue
  3. CUsing a queue makes task priorities unnecessary
Show answer and explanation

Answer: B. The receiver can sleep until data arrives, and differences in speed between sender and receiver are absorbed by the queue

Passing data through a shared variable and flag requires guarding against data races and having the receiver check repeatedly. With an RTOS queue, the sender simply puts data in and the receiver waits in a blocked state without using CPU until data arrives. Because several items can be buffered, no data is lost even if the sender is temporarily faster.

  • A. There is no encryption.
  • B. Correct. There is also no need to protect a shared variable manually.
  • C. Priorities are still needed.
Practice this topic Back to topic

More Embedded Systems & Firmware questions

  1. What is the difference between hard real-time and soft real-time?
  2. Why is it bad practice to kick (reset) the watchdog timer unconditionally inside a 1 ms timer interrupt handler?
  3. What is the role of a bootloader in an embedded device?
  4. In devices updated over the air (OTA), why is flash divided into two firmware slots (A and B)?
  5. What is the main purpose of using a microcontroller's sleep mode in a battery-powered embedded device?