Threading on UnixAuthor: Alec Flett <email@example.com>
Thanks to Wan-Teh Chang for much of this information
This document should clarify general confusion about different threading APIs/implementation in Mozilla and 3rd party libraries like glib/gtk.
- Native threads
- A thread implementation that is supported by a unix kernel. For example, Linux's native threads are created with the clone() system call without the COPYVM flag set.
- Threading Library
- A user-space library and API that provides user-level access to native or user level threads. For example, pthreads (also known as Posix Threads) is the most popular threading library. Some Unix flavors (Solaris and UnixWare) also have an older API to their native threads. This API is called Unix International (UI) threads, and uses the thr_ prefix.
Operating System Specifics
- The UI threads API is commonly referred to as Solaris threads.
- The Solaris (thr_) threadsAPI and pthreads API are just two different APIs to the same underlying native thread implementation, so they are fully compatible.
- You can't mix NSPR's user-level threads with the native pthreads. These two thread implementations are not compatible. You have to use the pthreads version of NSPR.
Mozilla, glib, and NSPR all do their own thread wrangling, so they must use compatible ways of interacting with threads. There are only a few ways of building all the libraries so that they are compatible:
gmake MOZILLA_CLIENT=1 USE_PTHREADS=1
- NSPR user-level threads
gmake MOZILLA_CLIENT=1(MOZILLA_CLIENT=1 makes user-level threads the default)
configure(default is to use user-level threads)