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

Discussion

A task and an interrupt handler share a 32-bit counter on an 8-bit core. Reading it in the task requires

  • A.the variable to be declared const as well as volatile
  • B.the handler to be given a higher priority than the task
  • C.a critical section, the read being made of several byte accesses
  • D.no protection, a single variable being inherently atomic

Answer: C

Four separate byte reads can be interrupted between any two of them, and the handler may increment the counter across a carry, so the value assembled is one that never existed. On a 32-bit core an aligned word read would be atomic and no protection would be needed.

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

Post your comment

Please log in or register to post a comment.