Deadlines

First submission deadline: 9 October
Final submission deadline: 16 October
This lab does not require passing a demo session.

Lab 3: Linda tuplespace

The objective of this assignment is to design and implement an Erlang module which implements a Linda-style tuple space and provides some of the standard tuple-space primitives.

The Interface

The interface to the module must consist of the following collection of functions:

new() – returns the PID of a new (empty) tuplespace.

in(TS,Pattern) – returns a tuple matching Pattern from tuplespace TS. Note that this operation will block if there is no such tuple.

out(TS,Tuple) – puts Tuple into the tuplespace TS.

Representing Tuples and Patterns

In the interface functions, tuples are naturally represented by Erlang tuples. The representation of patterns – in the definition of the in function - should use a single "wild card" pattern any. The following Erlang function match defines when a pattern (the first argument) matches a given tuple (the second argument):

match(any,_) -> true;

match(P,Q) when is_tuple(P), is_tuple(Q) -> match(tuple_to_list(P),tuple_to_list(Q));

match([P|PS],[L|LS]) -> case match(P,L) of true -> match(PS,LS); false -> false end;

match(P,P) -> true;

match(_,_) -> false.

For simplicity the function works at all types, not just tuple types.

Implementation and Submission Notes

The implementation of the tuplespace does not have to use an efficient data structure – although ideally your code should be written is such a way that it should be easy to replace your internal representation of the tuplespace with a more efficient one.

Requirements



Concurrent Programming 2016 - Chalmers University of Technology & Gothenburg University