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

Discussion

Comparing polling a volatile flag with blocking on a semaphore, the semaphore

  • A.lets the processor sleep or run other work while waiting
  • B.responds to the event with lower latency in every case
  • C.needs no protection against a race with the handler
  • D.can be used where no kernel is present

Answer: A

A busy loop burns the processor and prevents anything else running, whereas a blocked task costs nothing until the event arrives. The polling loop may actually respond a little sooner, since it avoids the context switch, and that is its only merit.

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

Post your comment

Please log in or register to post a comment.