多线程支持在C11 [英] Multi-Threading support in c11

查看:255
本文介绍了多线程支持在C11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的C11标准提供了多线程支持。结果
我的问题是有点多元化,但绝对听命。结果
我有看C11的 n1570 草案。结果
它说:

The new C11 standard provides a support for Multi-Threading.
My Questions are a bit diversified but definitely answerable.
I have had a look at the C11 n1570 draft.
It says:

对于多线程执行包括改进的内存排序支持
  模型,原子对象和线程本地存储(< stdatomic.h> < threads.h>

support for multiple threads of execution including an improved memory sequencing model, atomic objects, and thread-local storage (<stdatomic.h> and <threads.h>)

什么是在改进的内存时序模型?如何/从C99标准是什么变化?

What is the Improved memory sequencing model? How/What changes from the c99 Standard?

而不是仅仅从标准报价,我将AP preciate如果有人再往在其中更深层次,并试图解释所涉及的语义。

Rather than just quotes from standard, I will appreciate if someone delves deeper in them and tries explaining the semantics involved.

据我了解,C11提供了支持:

As I understand, C11 provides support for:


  • 线程的创建和管理

  • 互斥

  • 条件变量

  • 发具体的存储和放大器;

  • 原子对象

我希望我没有错过什么?结果
由于现在的标准库本身提供(提供)所有需要的多线程的功能,就没有必要POSIX和这样的库(多线程支持)的未来?

I hope I didn't miss anything?
Since now the Standard library itself provides(will provide) all the functionalities needed for Multi-Threading, there would be no need for POSIX and such libraries(for Multi-Threading support) in future?

最后,什么编译器上述功能提供支持?有没有以任何时间表时,参考这些将支持?结果
我记得C ++ 11有一个链接,编译器支持和特点,也许这样的事情?

Lastly, What compilers provide support for the above mentioned features? Are there any references as to timelines when these will be supported?
I remember for C++11 there was a link for compiler support and features, perhaps something like that?

推荐答案

第一,不要注销C ++ 11。新标准的并发工作是在C ++ 11的伞,然后导入到C11用的是兼容的明确目标下进行。虽然有一些语法差异(例如由于没有模板或函数重载纯C),语义它们是由设计完全相同。对于这个证据,可以检查WG14论文。例如:

First, don't write off C++11. The concurrency work for the new standards was done under the C++11 umbrella, then imported into C11 with the explicit goal of being compatible. While there are some syntactical differences (e.g. due to plain C not having templates or function overloading), semantically they are identical by design. For "evidence" of this, one can check the WG14 papers. E.g:

  • n1349
  • n1423
  • n1424
  • n1437
  • n1479
  • n1480
  • n1489
  • n1584

和其中的参考文献。更可以在这里找到
开放标准网站

and references therein. More can be found at Open Std Website

现在,在您的问题:

什么是改进内存时序模式?

明显的答案是,它已经改变,考虑到多线程以及它们如何相互作用。对于稍长的回答,请参阅C++11推出标准化的内存模型。这是什么意思?而究竟是怎样影响到C ++编程吗?一个已经在评论中提到。对于一个深入的了解,一个计算器的答案也许是不正确的地方(甚至更少有几个子问题一个问题!)。但幸运的是汉斯贝姆保持了非常好的页面,进一步阅读(又有趣的链接,请记住,在C11和C ++ 11内存模型在语义上是相同的)

The obvious answer is that it has been changed to take into account multiple threads and how they interact. For a slightly longer answer, see C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming? that was already mentioned in the comments. For an in-depth understanding, a stackoverflow answer is perhaps not the right place (even less a question with several subquestions!). But luckily Hans Boehm maintains a very good page with interesting links for further reading (again, keep in mind that the C11 and C++11 memory models are semantically identical)

我希望我没有错过什么?

加上内存模型,您的名单似乎涵盖在C11并发补充。对于其他的变化,维基百科有一个列表;我的头顶部的我不能拿出任何东西维基百科名单已经错过。

Together with the memory model, your list seems to cover the concurrency additions in C11. For other changes, wikipedia has a list; of the top of my head I can't come up with anything the wikipedia list has missed.

由于现在的标准库本身提供(提供)所有需要的多线程的功能,就没有必要POSIX和这样的库(多线程支持)的未来?

是,会有需要它们。首先,没有人会改写使用现有的各种线程API的所有现有code。其次,C(++)11线程库/将最有可能被实现为各地的各种原生线程库的包装;赫克,甚至还​​有以检索指向底层本地线程记录的方式,如果一个人需要做一些事情超出了C(++)线程库支持。想想C(++)11线程库更像各地的各种原生线程库便携,最小公分母包装。

Yes, there will be a need for them. First, nobody is going to rewrite all the existing code that uses the various existing thread API's. Secondly, the C(++)11 thread library is/will most likely be implemented as a wrapper around the various native thread libraries; heck, there's even a documented way to retrieve a pointer to the underlying native thread, in case one needs to do something beyond what the C(++) thread library supports. Think of the C(++)11 thread library more like a portable, least common denominator wrapper around the various native thread libraries.

最后,什么编译器提供上述功能的支持?有没有以任何时间表时,参考这些将支持?我记得C ++ 11有一个链接,编译器支持和特点,也许这样的事情?

我还没有看到任何详细的清单,似乎没有被周围C11尽可能多的嗡嗡声相比,C ++ 11。还有为即将到来的GCC 4.7这里的简短声明: http://gcc.gnu.org/gcc-4.7/changes html的。对于并发支持,可以为您在C ++的11状态页这里并发的支持:的http:// GCC。 gnu.org/projects/cxx0x.html 。还有的现状和计划GCC一些笔记在 http://gcc.gnu.org/wiki/Atomic (根据该网页,stdatomic.h可用)。对于其他的编译器,还有的在这里<一个各种编译器的C ++ 11的状态不错列表href=\"http://www.aristeia.com/C++11/C++11FeatureAvailability.htm\">http://www.aristeia.com/C++11/C++11FeatureAvailability.htm 。从链接有可以检查并发支持的状态,并假设有问题的供应商计划支持C11,C11的并发支持的话可能是在大约相同的水平。

I haven't seen any detailed list, there doesn't seem to be as much buzz around C11 compared to C++11. There's a short notice for the upcoming GCC 4.7 here: http://gcc.gnu.org/gcc-4.7/changes.html . For the concurrency support, one can check the support for concurrency in the C++11 status page here: http://gcc.gnu.org/projects/cxx0x.html . There's also some notes on the current status and plans for GCC at http://gcc.gnu.org/wiki/Atomic (according to that page, stdatomic.h is available). For other compilers, there's a nice list of the C++11 status for various compilers here http://www.aristeia.com/C++11/C++11FeatureAvailability.htm . From the links there one can check the status of the concurrency support, and assuming that the vendor in question plans to support C11, the C11 concurrency support is then likely to be at about the same level.

这篇关于多线程支持在C11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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