LIU Hao wrote:

> I'm wondering why anyone would link their multi-thread code against crtdll 
> nowadays.

This is the best option for NT 3.1 which does not support any version of 
msvcrt.dll. Also msvcrt.dll is not pre-installed before NT 4.0 and Windows 98.

> I'm also wondering why anyone would call prefer `_beginthreadex()` to 
> `CreateThread()`. Unlike Microsoft
> CRT, mingw-w64 CRT is linked against MSVCRT or UCRT DLL, where these 
> functions are almost identical, with
> similar parameters and semantics.

Unlike `CreateThread`, functions `_beginthread[ex]` also initialize CRT's 
per-thread state. Documentation[1] for `CreateThread` explicitly tells that if 
a thread calls any CRT function, it must instead call `_beginthread[ex]`. Pali 
can tell more about it, as he looked at it more closely.

Also, winpthreads' `pthread_create` uses `_beginthreadex` to spawn new thread 
and this emulation allows to build winpthreads with crtdll.dll/msvcrt10.dll. Me 
and Pali both tested such winpthreads build and it passes all tests locally.

​- Kirill Makurin

[1] 
https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createthread

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to