Shared Resource


The Shared Resource pattern is a specialisation of the Blackboard pattern [POSA96], lacking a control component and introducing aspects of activity parallelism, in which computations are performed, without a prescribed order, on ordered data. Commonly, components perform different computations on different data pieces simultaneously.

Examples

A Non-programming Example

Imagine a project of construction in general. An artifact (a building, a software program, a business program, etc.) is the result of the cooperation among several persons or teams, with different skills. Each one has different interests, responsibilities and perceptions of the project. All people or teams participate independently and simultaneously with different actions to achieve the result. A common objective and unity among them will produce a satisfactory result in time and consistent form.

A Programming Example

Consider a printed circuit board router program [Chien93]. A route is a series of wires or nets from one pin to another on a circuit board. Complex circuit boards might have a large number of routes. Routes must avoid obstacles on the board and other routes. A parallel implementation proposes to process each route by independent components, searching simultaneously on a data structure (representing the grid of coordinates on the board) for the shortest route between pins. Each component accesses the data structure, proposing a new probable free coordinate to add to its route from a given start point on the board. If this is occupied by an obstacle or another route, the component makes another proposal. Once a coordinate is added, each component calculates the lowest total distance estimate for its route.

Problem

It is necessary to apply completely independent computations as sets of non-deterministic interactions on elements of some centralised, perhaps not even ordered, data structure. Consider for example, a knowledge exchange problem. Components communicate via a shared resource, each one indicating its interest in a certain data object. The shared resource provides such data immediately if no other component is accessing it. Data consistency and preservation are tasks of the shared resource. The internal representation or order of data is important, but the order of operations on it is not a central issue. Generally, performance as execution time is the feature of interest.

Forces

Taking the previous problem description and other elements of parallel design such as granularity and load balance [Fos94, CT92], the following forces can be found:

Solution

Each component executes simultaneously, capable of performing different and independent operations, accessing the data as shared resource when needed. Parallelism is absolute among components: any component can be performing different operations on a different piece data at the same time, without any prescribed order. The restriction is that no piece of information is accessed at the same time by different components. Communication can be achieved as function calls to require a service from the shared resource. The Shared Resource pattern can be considered as an activity parallel variation of the Blackboard pattern [POSA96] without a control instance that triggers the execution of sources. An important feature is that the execution does not follow a precise order of computations [Shaw95, Pan96].

Structure

This pattern is based only on a shared resource as a central structure that controls the access of different sources. Usually, a shared resource component and several different source components simultaneously exist and process during the execution time (Figure 11).

Figure 11. Shared resource pattern.

Participants

Dynamics

A typical scenario to describe the basic run-time behaviour of the Shared Resource pattern is presented. All participants are simultaneously active. Every source performs a different operation, requiring the shared resource for operations. As soon as it finishes processing, returns to the calling source to continue its computations. Communications between sources are not allowed. The shared resource is the only common component among the sources (figure 12). The functionality of this general scenario is explained as follows:

Figure 12. Scenario of Shared resource pattern.

Implementation

The implementation process is based on the four stages mentioned above in the Context in general and Implementation in general sections.

Consequences

Benefits

Liabilities

Known uses

Related patterns

The Shared Resource pattern is considered a specialisation of the Blackboard pattern [POSA96] without control component, and introducing aspects of activity parallelism Also, it is related to the Repository architectural style [Shaw95, SG96]. Other patterns that can be considered related to this pattern are the Compatible Heterogeneous Agents pattern [ABM96] and the Object Group pattern [Maf96].

 


Contact Information

Jorge Luis Ortega Arjona.

E-mail jortega-arjona@acm.org