Machine-translated by Google. Questions are authored in English.
Top

Discussion

A task must wait for either a message or a 100 ms timeout, whichever comes first. This is done by

  • A.two tasks, one waiting on each condition
  • B.a mutex taken with a 100 ms timeout
  • C.polling the queue in a loop with a delay
  • D.a queue receive with a 100 ms timeout

Answer: D

Correct answer: a queue receive with a 100 ms timeout

The kernel primitive already does exactly this: it returns when a message arrives or when the timeout expires, whichever is first, and reports which happened. Polling in a loop wastes processor time and adds latency, and a second task or a mutex timeout solves a different problem.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.