-
Notifications
You must be signed in to change notification settings - Fork 32
How the MCF thread model works
LIU Hao edited this page Nov 17, 2024
·
5 revisions
The now committed patch implements compiler, linker and standard library support for the MCF thread model. The CRT part has not been committed to mingw-w64.
If GCC is configured with --enable-threads=mcf
:
- It has
__USING_MCFGTHREAD__
as a pre-defined macro, which enables special code paths in libstdc++ and mingw-w64 CRT. - It has
-lmcfgthread -lntdll
as default libraries. (NTDLL is only needed for static linking.) - It installs 'gthr-mcf.h' as 'bits/gthr-default.h', which is just a wrapper for 'mcfgthread/gthr.h'.
In libgcc, most use of threading infrastructure is internal. In libstdc++ there are some public functions that are to be replaced with MCF implementations:
-
__cxa_thread_atexit()
: On Linux it is provided in libstdc++ and jumps to__cxa_thread_atexit_impl()
in libc. Recent mingw-w64 provides this function, so it is opted out to prefer the mingw-w64 one. (There's a bug about it: https://github.com/msys2/MINGW-packages/issues/2519) -
__cxa_guard_acquire()
,__cxa_guard_release()
and__cxa_guard_abort()
: On Linux they are implemented with futexes. On most other platforms they are implemented with a single static mutex. They call__MCF_cxa_guard_acquire()
,__MCF_cxa_guard_release()
and__MCF_cxa_guard_abort()
, respectively.