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

Discussion

A circular buffer with one producer and one consumer can often be made lock-free because

  • A.the buffer is always accessed at the same rate by both
  • B.the kernel protects the indices automatically
  • C.a single-element buffer needs no indices at all
  • D.each party writes only its own index

Answer: D

The producer advances the write index and reads the read index; the consumer does the reverse. With aligned single-word indices and the right barriers no lock is needed, and adding a second producer destroys the property immediately.

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

Post your comment

Please log in or register to post a comment.