gpt4 book ai didi

c - 如何在 C 中编写线程安全、高效、无锁的内存分配器?

转载 作者:IT王子 更新时间:2023-10-28 23:36:55 26 4
gpt4 key购买 nike

如何在 C 中编写线程安全、高效、无锁的内存分配器?高效我的意思是:

  1. 快速分配和释放

  2. 优化内存使用(最小浪费且无外部碎片)

  3. 最小的元数据开销

最佳答案

http://www.research.ibm.com/people/m/michael/pldi-2004.pdf

This paper presents a completely lock-free memory allocator. It uses only widely-available operating system support and hardware atomic instructions. It offers guaranteed availability even under arbitrary thread termination and crash-failure, and it is immune to dead-lock regardless of scheduling policies, and hence it can be used even in interrupt handlers and real-time applications without requiring special scheduler support. Also, by leveraging some high-level structures from Hoard, our allocator is highly scalable, limits space blowup to a constant factor, and is capable of avoiding false sharing...

关于c - 如何在 C 中编写线程安全、高效、无锁的内存分配器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1995871/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com