Tagged Pointers for lockFree list in C

时光怂恿深爱的人放手 提交于 2019-12-02 03:27:29
Martin Zabel

The setTagMask function returns a modified version of the pointer p. If you store this modified pointer in your linked-list, then the list gets broken because the modified pointer does not point to a node anymore.

The pointer is modified as follows. The pointer p is converted to an unsigned integer which is capable to store a pointer: uintptr_t. Then one or more bits are set according to MASK_BIT. Finally, the result is converted back to a pointer and returned.

The function isMaskFlagSet checks whether the mask bits are still set.

The only use case, I can image is: you have to call isMaskFlagSet every time, before you use the pointer. If the mask bits are set, then it is prohibited to actually use the pointer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!