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

Discussion

A driver holding its state in file-scope statics is made safe for two tasks by

  • A.making the driver's functions inline
  • B.serialising the callers with a mutex inside the driver
  • C.declaring the statics volatile
  • D.giving both of the calling tasks the very same priority

Answer: B

Correct answer: serialising the callers with a mutex inside the driver

Shared state needs mutual exclusion, and a mutex inside the driver provides it without every caller having to remember. volatile addresses visibility rather than exclusion, equal priorities do not prevent preemption, and inlining changes nothing at all.

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

Post your comment

Please log in or register to post a comment.