zoukankan      html  css  js  c++  java
  • liburcu 库

    今天在看sheepdog源代码的时候,发现它的log系统使用了liburcu这个库里面的函数,详细调研了一下。

    读取拷贝更新,意思就是说,在要进行update的时候,先保留旧数据,然后替换新数据;再等待旧数据无人使用后,删除旧数据。从它的思想可以看到它写入数据的开销比较大,因为要等待所有读取线程都不在使用旧数据为止。这种结构比较适合用在很多线程读,但只有少量写的地方。

    Linux核心提供了基于RCU的锁函数。但在用户态下,需要自己调用其他库,比如liburcu这个库。

    liburcu is a LGPLv2.1 userspace RCU (read-copy-update) library. This data synchronization library provides read-side access which scales linearly with the number of cores. It does so by allowing multiples copies of a given data structure to live at the same time, and by monitoring the data structure accesses to detect grace periods after which memory reclamation is possible.

    liburcu-cds provides efficient data structures based on RCU and lock-free algorithms. Those structures include hash tables, queues, stacks, and doubly-linked lists.

    等详细看完sheepdog如何使用这些库的时候,再更新这个博客.

    这个文档只有在0.7.5版本的doc目录下有,rcu-api.txt  uatomic-api.txt

    介绍RCU:

    http://lwn.net/Articles/262464/

    liburcu库:

    http://lttng.org/urcu

  • 相关阅读:
    iOS input disabled显示不清楚
    钉钉小程序——JSAPI
    留言板
    友链
    mysql---存储引擎
    union与limit
    spring--setter注入
    spring---生命周期
    sql03-连接查询
    sql01--认识表
  • 原文地址:https://www.cnblogs.com/zhangzhang/p/2844358.html
Copyright © 2011-2022 走看看