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