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

标签 c multithreading memory performance allocation

如何在 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/

相关文章:

c++ - 为什么线程对类变量所做的更改没有影响?

c++ - 使用 memory_order_relaxed 进行存储,使用 memory_order_acquire 进行加载

r - 如何使用 foreach 克服内存限制

c++ - 录像机的多线程

C正确退出程序

c - 传递给嵌套函数的字符串文字指针问题

c - C中的字符串交换

Java 本地方法调用没有响应

ios - GuardMalloc 导致虚拟内存耗尽

c - 我应该在 Mac OS X 上使用哪个 libc strcpy/strlcpy/strncpy?