The dRuby Book

6.1 Introducing Linda and Rinda

Rinda is a Ruby implementation of the Linda tuple space, which is a distributed processing system. To use Linda, you need to understand two concepts: tuples and tuplespaces. A tuple is data, and a tuplespace is a distributed shared memory. Each task can communicate with the other by writing into or reading from the tuplespace.

The concept of a tuple is similar to a memo in the real world. As you pass around a memo in your office to relay some information regarding your business, you send it from one person to the other. In the world of Rinda, the “memorandum” tuple walks from process to process via TupleSpace.

Linda is fairly simple; it allows you to do complex interprocess communication easily.

Linda

When you write parallel programs, you usually need two kinds of programs: one to describe how to process computation and another to coordinate the processing programs. The coordination language acts as a glue that holds together individually written programs. Linda is one of the coordination languages and was developed by David Gelernter and other contributors.

Linda has six different operations to access tuple space (see Figure 30, How Linda's in and out operations work). Linda is usually provided as an extension of existing languages, such as C (the C extension version of Linda is called C-Linda) and Fortran. Linda allows you to coordinate across different programming languages or operating systems.

images/d2linda.png

Figure 30. How Linda’s in and out operations work
out

Puts a tuple into the tuplespace.

in

Takes out a tuple that matches a given pattern from tuplespace. If there’s no matching tuple, it blocks the operation.

rd

Copies a tuple that matches a given pattern from tuplespace. If there’s no matching tuple, it blocks the operation.

inp

Nonblocking version of in. If there’s no matching tuple, it returns an error message.

rdp

Nonblocking version of rd. If there’s no matching tuple, it returns an error message.

eval

Starts a new process and evaluates it.

Rinda

Rinda is a library to coordinate Ruby programs among different threads or different processes. It’s similar to Linda in the sense that it can communicate across different operating systems as long as Ruby runs on it.

Rinda implements some important concepts of Linda, such as “tuple,” “tuple- space ,” “in,” and “out” operations. “in” and “out” in Linda are renamed to take and write. These names came from a Java version of Linda called Java- Spaces. “eval” is not implemented as part of the standard library, but you can add it (we’ll discuss this more in Chapter 8, Parallel Computing and Persistence with Rinda).

Those are the only differences between Rinda and Linda. You can apply the majority of Linda’s concepts to Rinda.