Download presentation
Presentation is loading. Please wait.
Published byClement Shelton Modified over 9 years ago
1
Ioana BurceaWon-Ho Park Electrical and Computer Engineering Department University of Toronto Algorithms for Implementation of Tuple Space Expert Topic ECE 1770 Spring 2003
2
Agenda l Ioana - Matching Algorithms (in Linda) u Basic Terminology and Concepts u Multi-Key Search Algorithm l Won-Ho - Linda: Implementation of Tuple Space
3
Basic Terminology l Tuple (out operation) - Ex: u (1, 4.0, “Middleware”) l Template = antituple (in operation) - Ex: u (1, 4.0, ?x) x: string u (1, 4.0, “Middleware”) l Tuple arity - Ex: u (1, ?x) arity 2 u (1, 4.0, “Middleware”) arity 3 l Type signature - Ex: u (1, 4.0, “Middleware”) (int, float, string)
4
Matching Algorithms l Exhaustive search – too time consuming l Optimizations - Segmenting u Orthogonal subspaces - Based on »tuple arity & type signature »constants - Treated separately - Searching u Zero variable case - In(“mutex”)Out(“mutex”) u One variable case - Single key index u Multiple variable - Multiple key search
5
Patterns l Actual parameter - Ex: u (1, 4.0, “Middleware”) 1, 4.0, “Middleware” u (1, 4.0, x) 1, 4.0, x l Formal parameter (placeholder / wildcard) - Ex: u ?x (x: string) l Tuple Pattern - Bitvector u its size is given by the arity of the tuple u a bit is set if and only if it corresponds to a actual parameter - Ex: u (1, 4.0, “Middleware”) (111) u (1, 4.0. ?x) (110)
6
Matching Semantics Using Patterns l Compatible patterns - Two tuples P and Q are compatible if and only if P OR Q contains only 1s l Two tuples may match if and only if their patterns are compatible l Must-match pattern - Ex: u Out(a, b, c) pattern (111) u In (x, ?y, z) pattern (101) l Matching definition - Two tuples match if and only if u They have the same type signature u Exactly one is an antituple u Their patterns are compatible u Their must-match values are equal OR = (111) compatible AND = (101) must-match pattern
7
Multiple key search l Applied inside each orthogonal subspace l Basic idea: - Build the key search based on the pairs of compatible patterns and must-match values l Ex: - Tuple pattern: (111) - Antituple patterns: (010), (100), (110) u an entry in the dictionary for each pair (tupple pattern, antituple pattern) => each tuple will be referenced by multiple keys u the key of the entry also contains the must-match values u the entry points to the tuple u Ex: out(3, 5, x) => Key: (010:111:5) - ! One record per must-match pattern is not sufficient ! l Property: - If two tuples have the same key => they match l Perfect hash function – one to one correspondence between search keys and the hash keys
8
Offline Algorithm – in operation 1) Lock subspace 2) Identify antituple’s pattern, p, and store antituple where it can be found via a pointer or other reference. 3) For each compatible tuple pattern, c, in use, 4) Combine p, c, and antituple’s must-match values to form a search key, k. 5) Search dictionary for a tuple reference indexed by k. 6) If one is found, then 7) Delete tuple, antituple and all their references. 8) Goto 10. else 9) Insert a reference to antituple, indexed by k, into dictionary. 10) Unlock subspace 11) If no match was found, then 12) Suspend execution until signalled else 13) Return match result
9
Online Algorithm l Adapt the tuple space whenever a new pattern is encountered 2.1) If p is a new antituple pattern, then 2.2) Create a new list for p 2.3) For each old, compatible tuple pattern q 2.4) For each tuple t on q’s list 2.5) Insert into dictionary a new reference to t, based on p and q 2.6) Insert antituple in p’s list l Discussion - Usually, no perfect hash u Each hash entry has a hash chain u The hash chain has to be checked until a match is found
10
Virtual Linda Machine (VLM): Implementation of Linda on Networks l TupleSpaces is a virtually shared memory: - How to implement TupleSpaces in the absence of shared memory - How to find Tuples and where keep them l Components of VLM - Hardware - Network Communication Kernel - Compiler l Hardware is networks, or network computers l The kernel is the program resident on each network node that implements inter-node communication - Performing In(), out(), read() primitive instructions on networks by sending or broadcasting messages l The compiler adds code for maintaining buffer (shared memory)
11
Run-Time Name Resolution in VLM: How to find Tuples l VLM should provide Name(Tuple)-to-Node(address) mapping information - Centralized in directory nodes - Distributed network-wide (e.g., by means of a network-wide broadcast) l The communication kernel translates Tuple-names into network-addresses on a per-reference basis l Network state and its storage - Only one node generating state information maintains the state - All nodes maintain all state by broadcasting - VLM uses N 1/2 -Node Broadcast Technique.
12
N 1/2 -Node Broadcast Technique and Name Resolution l Write set : row nodes l Read set : column nodes l P-in-thread process l P-out-thread process l P-in-thread is intercepted by a P-out-thread on node k. l A notification message is generated on k-node, and sent to m-node l The message instructs m-node to send tuple(P…) to n-node. m P-out-thread Out(P…) In(P…) kn P-in-thread A Network Topology
13
Buffering: Where to keep Tuples l VLM is required to simulate Linda’s infinite global buffer l Buffer is allocated by the compiler-generated code, not by the kernel - in(P….) : allocating a buffer on the execution stack of the process, and referred to buffer P. - out(P…) : Tuples are stored in per-process heaps, and destroyed when it is delivered - Header information required by the communication system l If a process terminates with undelivered Tuples - The buffers are maintained by the communication kernel until delivery occurs
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.