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

Discussion

Making that counter volatile would

  • A.fix the race by making each access indivisible
  • B.fix the race by preventing the compiler from reordering
  • C.fix the race only on a 32-bit processor
  • D.not fix the race, volatile guaranteeing nothing about atomicity

Answer: D

The qualifier stops the compiler caching the value in a register; it says nothing about a preemption falling between two machine instructions. Believing otherwise is one of the most persistent misconceptions in embedded C.

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

Post your comment

Please log in or register to post a comment.