内存栅栏/ C ++中的障碍:不提升或其他图书馆让他们? [英] memory fences/barriers in C++: does boost or other libraries have them?

查看:349
本文介绍了内存栅栏/ C ++中的障碍:不提升或其他图书馆让他们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读这些天关于内存围栏和障碍的方式来同步多线程code和避免code重新排序。

I am reading these days about memory fences and barriers as a way to synchronize multithreaded code and avoid code reordering.

我一般都是用C ++开发在Linux操作系统下,我用升压库大规模,但我无法找到与之相关的任何类。你知道,如果围栏的内存屏障是present升压或者如果有一种方法来达到同样的概念?如果没有什么好图书馆,我可以看看什么?

I usually develop in C++ under Linux OS and I use boost libs massively but I am not able to find any class related to it. Do you know if memory barrier of fences are present in boost or if there is a way to achieve the same concept? If not what good library can I have a look to?

推荐答案

有升压没有低级内存屏障还没有,但它提供他们一个建议boost.atomic库。

There are no low-level memory barriers in boost yet, but there is a proposed boost.atomic library that provides them.

编译器提供自己无论是作为内部函数或库函数,如gcc的 __ sync_synchronize() _mm_mfence()为Visual Studio。

Compilers provide their own either as intrinsics or library functions, such as gcc's __sync_synchronize() or _mm_mfence() for Visual Studio.

本的C ++ 0x库提供原子操作包括在<一的形式存储栅栏href=\"http://www.stdthread.co.uk/doc/headers/atomic/atomic_thread_fence.html\"><$c$c>std::atomic_thread_fence.虽然自V4.4 GCC有提供各种形式的C ++ 0x原子能的,既不V4.4或V4.5包括这种形式的围栏。我的(商业) 刚刚::线程 库提供了一个全面实施的C ++ 0x中原子公司,包括围栏的G ++ 4.3和4.4,和Microsoft Visual Studio 2005,2008和2010。

The C++0x library provides atomic operations including memory fences in the form of std::atomic_thread_fence. Though gcc has supplied various forms of the C++0x atomics since V4.4, neither V4.4 or V4.5 include this form of fence. My (commercial) just::thread library provides a full implementation of C++0x atomics, including fences for g++ 4.3 and 4.4, and Microsoft Visual Studio 2005, 2008 and 2010.

这篇关于内存栅栏/ C ++中的障碍:不提升或其他图书馆让他们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆