English 中文(简体)
c
原标题:Multi-Threading support in c11

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:

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

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

我不只引用标准,而是希望有人会更深入地参与,并试图解释所涉的语义。

如我所知,C11支持:

  • Thread creation and Management
  • Mutex
  • Conditional Variables
  • Thread Specific storage &
  • Atomic Objects

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?

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型平原没有模板或功能超载),但从理论上讲,这些差异在设计上是相同的。 对于“证据”而言,可以核对工作组14份文件。 例如:

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

现在,关于你的问题:

www.un.org/Depts/DGACM/index_spanish.htm 改善记忆排序模式是什么?

显而易见的答案是,它已经改变,以考虑到多个线索及其互动方式。 答案略长,见 这些意见已经提到。 深入了解,分流答案或许不是正确的地点(甚至更不用说几个分问题!) But luckily 。 汉斯·博赫姆保持了一个非常好的网页,有令人感兴趣的链接可进一步阅读<(同时牢记C11和C++11记忆模型在理论上相同)。

www.un.org/Depts/DGACM/index_spanish.htm 我希望我没有错过任何东西?

随同记忆模式,你的名单似乎涵盖了C11的一致增加。 在其他改动中,wikipedia有一份名单;在我的上任人中,我可以拿到任何离去的烟道清单。

www.un.org/Depts/DGACM/index_spanish.htm 从现在起,标准图书馆本身提供(将提供)多种翻新所需的所有功能,因此今后没有必要设立PPOSIX和这类图书馆(用于多翻新支助)?

是的,它们将需要。 首先,任何人都不会篡改使用各种现有读物编号的所有现行法规。 第二,C(++)11 校对图书馆是/最有可能在各种本土阅读图书馆周围作为包裹加以实施;在需要做超出C(++)校对图书馆所支持的内容的情况下,黑板甚至有文件可查地检索底土线的线人。 阅读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相比,C11周围似乎有点燃烧。 即将到来的海合会4.7号通知如下:。 关于赞同性支持,可核实对C++11现状页的赞同性::http://gcc.gnu.org/projects/cxx0x.html。 关于海合会目前状况和计划的一些说明,见http://gcc.gnu.org/wiki/Atomic” rel=“noreferer”http://gcc.gnu.org/wiki/Atomic。 (根据该页,可提供住所。) 对于其他汇编者而言,此处有C++11不同汇编者地位的单号清单:。 http://www.aristeia.com/C++11/C++11FeatureAvailability.htm。 从这些链接中,人们可以检查一致支持的状况,并假设有关供应商计划支持C11,那么C11的一致支持可能达到同样水平。

Regarding What compilers provide support for the above mentioned features?


Pelles C supports C11 <threads.h>. Creation of threads with Pelles C compiler example:
#include <stdio.h>
#include <threads.h>

#define NUM_THREADS 7

static int threadData[NUM_THREADS];

int threadFunction(void * data) {
    printf("%d-th thread up
", *(int*)data);
    return 0;
}

int main(void) {
    thrd_t threadId[NUM_THREADS];

    // init thread data
    for (int i=0; i < NUM_THREADS; ++i)
        threadData[i] = i;

    // start NUM_THREADS amount of threads
    for (int i=0; i < NUM_THREADS; ++i) {
        if (thrd_create(threadId+i, threadFunction, threadData+i) != thrd_success) {
            printf("%d-th thread create error
", i);
            return 0;
        }
    }

    // wait until all threads terminates
    for (int i=0; i < NUM_THREADS; ++i)
        thrd_join(threadId[i], NULL);

    return 0;
}

www.un.org/Depts/DGACM/index_spanish.htm 消除现成的共同数据问题和从<代码>main(<>>>>>>>中退出的问题,比所有校对都早终止。

Janneb已经做了许多解释。 最后一个问题

Lastly, What compilers provide support for the above mentioned features? Are there any references as to timelines when these will be supported?

编辑者(大地、ic、开放式)的热情家庭支持新标准所要求的大多数杂质,但只存在明显的差异。 (clang 甚至在最新版本中实施_Generic。)

http://p99.gforge.inria.fr/“rel=“nofollow” 我写了wrapper XI。 该表将大部分特征描绘成已经是C11 syntax或接近C11的特征(用于复制_Generic)。

因此,如果你有一个编印人和<>>m>,那么你可以立即开始使用C11的批号(多数):所有类型(<代码>mtx_h的校对、有<代码>的原子、普通大体(子轴略不同于C11)、<代码_Static_assert/code>和校对等。





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...