Monthly Archives: November 2017

Concurrent Programming in Prolog

This week, Tamara gave a presentation on her Part II project – implementing Concurrent Prolog. Tamara began by explaining how most programs only use one core of the CPU, and how her aim was to utilize multiple cores concurrently in Prolog and thus speed up computation.

She went on to explain the 4 fundamental rules of concurrency:

  • Atomicity – Either all actions of a transaction are carried out, or none are.
  • Consistency – Every action applied to consistent data leaves the data in a consistent state
  • Isolation – Operations are isolated, protected from the effects of other concurrently executed operations.
  • Durability – If an operation completes successfully, its effects persist.

To illustrate the benefits of concurrency, Tamara then demonstrated an example of using concurrency when walking a tree in Prolog. Since Prolog is a declarative programming language, there is no shared data when evaluating Prolog Facts and Rules, which turns out to be beneficial when implementing concurrency.

Tamara then outlined two possible implementations of concurrency:

  • Pool of threads: Using multiple worker threads that were able to claim and perform tasks that were held in a stack declared on the main thread.
  • Work stealing: Each worker thread has its own stack of tasks that it works through, stealing work from other threads if its stack is empty.

At the end of the talk, Tamara answered all sorts of fun and tricky questions. Everyone had the chance to give structured feedback on the presentation, using the techniques from Dr Rice’s presentation last week.

prolog_concurrency

Advertisements