realism
V2EX  ›  问与答

Windows 上使用 pthread.h 会有性能损失吗?

  •  
  •   realism · Sep 8, 2022 · 2099 views
    This topic created in 1544 days ago, the information mentioned may be changed or developed.

    我知道 Linux 上才有 POSIX 线程,但手头一套 Linux 代码在 Windows 上用 mingw 可以实现编译( mingw 应该自行提供了一套 pthread 适配层)。

    同时我们也知道,有 pthreads-win32 这样的库提供了 windows 上的 pthread 实现。

    我想知道,这两种方式编译的多线程程序,相比用 windows.h 里的 CreateThread() 会有性能损失吗?哪个损失多一点?

    1 replies  •  2022-09-08 17:49:50 +08:00
    ysc3839
    ysc3839
    Sep 8, 2022❤️1
    1
    理论上不会,pthread API 应该都能对应上 Win32 原生 API 。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   999 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 18:56 · PVG 02:56 · LAX 10:56 · JFK 13:56
    ♥ Do have faith in what you're doing.