9 Multithreaded 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 multithreading 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. The SWI-Prolog thread implementation has been discussed in the ISO WG17 working group and is largely addopted by YAP and XSB Prolog.138The latest version of the ISO draft can be found at http://logtalk.org/plstd/threads.pdf. It appears to have dropped from the ISO WG17 agenda.


Section Index


9.1 Creating and destroying Prolog threads
9.2 Monitoring threads
9.3 Thread communication
9.3.1 Message queues
9.3.2 Signalling threads
9.3.3 Threads and dynamic predicates
9.4 Thread synchronisation
9.5 Thread support library(threadutil)
9.5.1 Debugging threads
9.5.2 Profiling threads
9.6 Multithreaded mixed C and Prolog applications
9.6.1 A Prolog thread for each native thread (one-to-one)
9.6.2 Pooling Prolog engines (many-to-many)
9.7 Multithreading and the XPCE graphics system