2

它是否使用 pthreads 或其他一些线程 API?

4

3 回答 3

5

是的,Linux 上的 gcc 使用 pthreads。

于 2012-06-01T16:04:27.817 回答
1

这取决于你用什么编译 GCC,标准的 linux 实现带有用于 OpenMP 的 posix 线程,gcc -v在终端上输入

这是我笔记本电脑的输出,感兴趣的部分以粗体显示

[n@N-pc-t61 ~]$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-redhat-linux/4.6.3/lto-wrapper
Target: i686-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch=i686 --build=i686-redhat-linux
**Thread model: posix**

这是 gcc 网站上所有可用的选项

--enable-threads=lib
    Specify that lib is the thread support library. This affects the Objective-C compiler and runtime library, and exception handling for other languages like C++ and Java. The possibilities for lib are:

    aix
        AIX thread support.
    dce
        DCE thread support.
    lynx
        LynxOS thread support.
    mipssde
        MIPS SDE thread support.
    no
        This is an alias for `single'.
    posix
        Generic POSIX/Unix98 thread support.
    rtems
        RTEMS thread support.
    single
        Disable thread support, should work for all platforms.
    tpf
        TPF thread support.
    vxworks
        VxWorks thread support.
    win32
        Microsoft Win32 API thread support. 
于 2012-06-01T16:16:07.703 回答
0

一个 OpenMP 运行时库是 OdinMP 编译器所针对的 Balder 库。该库和编译器完全支持 OpenMP 2.0,包括嵌套并行。Balder 库采用模块化设计,并具有多个子库。一个这样的子库是一个名为 Balder Threads 的高效可移植线程库

于 2012-06-01T16:05:53.417 回答