|
From: | Bruno Haible |
Subject: | doc: New chapter 'Multithreading' |
Date: | Tue, 02 Jun 2020 00:48:48 +0200 |
User-agent: | KMail/5.1.3 (Linux/4.4.0-177-generic; KDE/5.18.0; x86_64; ; ) |
The support for the three multithreading APIs is complete in Gnulib since 2020-01-19, except for the documentation. Let me now document it. 2020-06-01 Bruno Haible <bruno@clisp.org> doc: New chapter 'Multithreading'. * doc/multithread.texi: New file. * doc/gnulib.texi: Include it.
0001-doc-New-chapter-Multithreading.patch
Description: Text Data
Next: Particular Modules, Previous: Native Windows Support, Up: Top [Contents][Index] 14 MultithreadingMultithreading is a programming paradigm. In a multithreaded program, multiple threads execute concurrently (or quasi concurrently) at different places in the program. There are three motivations for using multithreading in a program:
A multithreading API offers
Note: Programs that achieve multithreading through OpenMP (cf. the gnulib module ‘openmp’) don’t create and manage their threads themselves. Nevertheless, they need to use mutexes/locks in many cases.
Next: Choosing a multithreading API, Up: Multithreading [Contents][Index] 14.1 The three multithreading APIsThree multithreading APIs are available to Gnulib users:
They are supported on all platforms that have multithreading in one form or the other. Currently, these are all platforms supported by Gnulib, except for Minix. The main differences are:
Next: POSIX multithreading, Previous: Multithreading APIs, Up: Multithreading [Contents][Index] 14.2 Choosing the right multithreading APIHere are guidelines for determining which multithreading API is best for your code. In programs that use advanced POSIX APIs, such as spin locks,
detached threads ( In code that is shared with glibc, it is best to use the POSIX API as well. In libraries, it is best to use the Gnulib API. This is because it gives the person who builds the library an option ‘--enable-threads={isoc,posix,windows}’, that determines on which native multithreading API of the platform to rely. In other words, with this choice, you can minimize the amount of glue code that your library needs to contain. In the other cases, the POSIX API and the Gnulib API are equally well suited. The ISO C API is never the best choice, as of this writing (2020). Next: ISO C multithreading, Previous: Choosing a multithreading API, Up: Multithreading [Contents][Index] 14.3 The POSIX multithreading APIThe POSIX multithreading API is documented in POSIX https://pubs.opengroup.org/onlinepubs/9699919799/. To make use of POSIX multithreading, even on platforms that don’t support it natively (most prominently, native Windows), use the following Gnulib modules:
There is also a convenience module named Next: Gnulib multithreading, Previous: POSIX multithreading, Up: Multithreading [Contents][Index] 14.4 The ISO C multithreading APIThe ISO C multithreading API is documented in ISO C 11 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf. To make use of ISO C multithreading, even on platforms that don’t support it or have severe bugs, use the following Gnulib modules:
There is also a convenience module named Previous: ISO C multithreading, Up: Multithreading [Contents][Index] 14.5 The Gnulib multithreading APIThe Gnulib multithreading API is documented in the respective include files:
To make use of Gnulib multithreading, use the following Gnulib modules:
The Gnulib multithreading supports a configure option ‘--enable-threads={isoc,posix,windows}’, that chooses the underlying thread implementation. Currently (2020):
Previous: ISO C multithreading, Up: Multithreading [Contents][Index] |
[Prev in Thread] | Current Thread | [Next in Thread] |