Did you know ... Search Documentation:
Pack logtalk -- logtalk-3.86.0/examples/threads/NOTES.md

This file is part of Logtalk https://logtalk.org/ SPDX-FileCopyrightText: 1998-2023 Paulo Moura <pmoura@logtalk.org> SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

This folder contains several examples of multi-threading programming. Multi-threading programming is only supported on some Prolog compilers. Currently this includes SWI-Prolog, YAP, and some XSB versions (make sure that you use the multi-threading versions of these Prolog compilers!). Moreover, multi-threading may be turned off by default. In order to run the examples, you may need to first turn on multi-threading support on the Prolog adapter files.

Some examples try to benchmark single-threaded vs multi-threaded solutions. Depending on the Prolog compiler, the operating-system, and the computer used, you may need to adjust the size of the problem data in order to find the threshold where multi-threading solutions begin to outperform the single-threaded solutions.

Some examples may imply adjusting the default size of thread data areas or, preferably, use of the 64 bits version of the compatible Prolog compilers.

There are known Prolog bugs on the multi-threading support found on XSB and YAP. These bugs prevent some examples to run and may lead to crashes. Some bugs are platform-specific, only occurring on some operating-systems.

Follows a short description of the included example (in alphabetical order):

[98, 97, 114, 114, 105, 101, 114, 115]
barrier synchronization using threaded notifications
[98, 105, 114, 116, 104, 100, 97, 121, 115]
using threads to represent agents
[98, 108, 97, 99, 107, 98, 111, 97, 114, 100]
synchronization of threads using shared resources
[98, 117, 99, 107, 101, 116, 115]
atomic updates example
[98, 117, 102, 102, 101, 114]
synchronizing threads writing to and reading from a buffer
[99, 104, 101, 99, 107, 112, 111, 105, 110, 116]
using a barrier as a checkpoint to synchronize a set of worker threads assembling a set of items
[102, 102, 116]
multi-threading computation of the Fast Fourier Transform
[102, 105, 98, 111, 110, 97, 99, 99, 105]
multi-threading solution for computing Fibonacci numbers
[102, 117, 110, 99, 116, 105, 111, 110, 115]
competitive or-parallelism computation of functions
[104, 97, 110, 111, 105]
multi-threading version of the "Towers of Hanoi" problem
[105, 110, 116, 101, 103, 114, 97, 116, 105, 111, 110]
multi-threading implementation of recursive Gaussian quadrature methods for numerical integration of functions of one variable
[105, 110, 116, 101, 103, 114, 97, 116, 105, 111, 110, 50, 100]
multi-threading implementation of recursive Gaussian quadrature methods for numerical integration of functions of two variables
[109, 101, 116, 101, 114, 101, 100, 95, 99, 111, 110, 99, 117, 114, 114, 101, 110, 99, 121]
an implementation of a metered concurrency task
[109, 116, 98, 97, 116, 99, 104]
multi-threading benchmarks for and-parallelism and competitive or-parallelism
[110, 111, 110, 100, 101, 116]
non-deterministic multi-threading calls
[112, 104, 105, 108, 111, 115, 111, 112, 104, 101, 114, 115]
classical "dining philosophers" problem using threads
[112, 105, 110, 103, 95, 112, 111, 110, 103]
two threads playing a ping-pong game
[112, 114, 105, 109, 101, 115]
multi-threading computation of prime numbers in a given interval
[115, 111, 114, 116, 105, 110, 103]
multi-threading implementation of the merge sort algorithm
[115, 121, 110, 99]
synchronization of predicates with side-effects
[116, 97, 107]
multi-threaded implementation of the Takeuchi function
[116, 101, 97, 109]
an implementation of a synchronous concurrency task