为什么升压lockfree空闲列表的大小限制为最多65535的对象? [英] why is boost lockfree freelist size is limited to a maximum of 65535 objects?
问题描述
为什么升压lockfree尺寸固定为65535对象?
Why is the boost lockfree size is fixed to 65535 objects?
typedef boost::lockfree::queue<int, boost::lockfree::fixed_size<true>> MyQueue;
MyQueue queue(1024*100);
以上code抛出异常。
The above code throws exception.
我在code找到的理由是,基于阵列的自由列表只支持一个16位的地址空间。
the reasoning i find in the code is that array-based freelists only support a 16bit address space.
是什么原因呢?我使用它的64位Linux机器上。那么为什么限制的寻址到2 ** 16个项目?不排队使用索引一个短整型?没有原子操作仅适用于16位字长的工作?
what is the reason for this? i am using it on 64bit linux machine. then why limit the addressing to 2**16 items? does the queue use a 'short int' for indexing? does atomic instructions only work for 16bit word size?
我应该做有一个固定大小的队列比这更大的容量?
what should i do to have a fixed sized queue with more capacity than this?
推荐答案
lockfree列表加速实现必须打的 ABA问题的。一个常见的解决方法是额外的标记
位增加的数量正在考虑中。此外,升压有在32位架构上运行,这意味着只有32位的值可以原子进行操作。
Boost implementation of lockfree list has to fight the ABA problem. A common workaround is to add extra tag
bits to the quantity being considered. Furthermore, Boost has to run on a 32-bit architecture, this means only 32-bit values can be manipulated atomically.
如果我们分手的32位值,我们可以存储16位指针和16位的标签。 16位无符号值限制在65535不同的值。
And if we split 32-bit value we can store 16-bit pointers and 16-bit tag. Unsigned 16-bit values are limited to 65535 different values.
这篇关于为什么升压lockfree空闲列表的大小限制为最多65535的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!