8 Multi-threaded applications

SWI-Prolog multithreading is based on standard C-language multithreading support. It is not like ParLog or other parallel implementations of the Prolog language. Prolog threads have their own stacks and only share the Prolog heap: predicates, records, flags and other global non-backtrackable data. SWI-Prolog thread support is designed with the following goals in mind.

SWI-Prolog multi-threading is based on the POSIX thread standard Butenhof, 1997 used on most popular systems except for MS-Windows. On Windows it uses the pthread-win32 emulation of POSIX threads mixed with the Windows native API for smoother and faster operation.


Section Index


8.1 Creating and destroying Prolog threads
8.2 Monitoring threads
8.2.1 Linux: linuxthreads vs. NPTL
8.3 Thread communication
8.3.1 Message queues
8.3.2 Signalling threads
8.3.3 Threads and dynamic predicates
8.4 Thread synchronisation
8.5 Thread-support library(threadutil)
8.5.1 Debugging threads
8.5.2 Profiling threads
8.6 Multi-threaded mixed C and Prolog applications
8.6.1 A Prolog thread for each native thread (one-to-one)
8.6.2 Pooling Prolog engines (many-to-many)
8.6.2.1 Engines in single-threaded SWI-Prolog
8.7 Multithreading and the XPCE graphics system