使用RCU避免在更新时使用互斥

http://en.wikipedia.org/wiki/Read-copy-update

 

The name comes from the way that RCU is used to update a linked structure in place. A thread wishing to do this uses the following steps:

  • create a new structure,
  • copy the data from the old structure into the new one, and save a pointer to the old structure,
  • modify the new, copied, structure
  • update the global pointer to refer to the new structure, and then
  • sleep until the operating system kernel determines that there are no readers left using the old structure, for example, in the Linux kernel, by using synchronize_rcu().

When the thread which made the copy is awakened by the kernel, it can safely deallocate the old structure.

你可能感兴趣的:(structure,thread,system,linux,linux开发)