CS 771/871 Operating Systems
[ Home | Class
Roster | Syllabus | Status | Glossary
| Search | Course
Notes]
Linda's Tuple Space
- Tuple
- Object containing
"n" fields, each of a particular data type
Like a record or structure in other
languages
- Each tuple can be
characterized by a SIGNATURE
- defined by its size and the
type of its field
NOTE: the parameter list of a
function or procedure is also defined by a tuple and its
signature
Examples
("jim", 3, 535.67)
("mary", 4, 654.34)
are both tuples of signature
(string, integer, fixed point number)
(the integer might be the employee number and the fixed
point number the weekly salary)
Because each tuple signature
characterizes it, the signature can be used to partition the
tuple space
- on length
- on the type of any and all
fields
- on the value of some subset of
the fields
Operations in LINDA
- out("jim", 3,
535.67) : puts this tuple into the tuple space
- out("mary", 5,
salary) : some fields can be variables
- in("jim", 3, ?
salary)
- gets a tuple which
matches name "jim" and employee
number "3", and assigns the value
found in that tuple to "salary",
erases the tuple from the tuple space
- If there was no tuple
matching "jim" and "3",
the operation would block, waiting for a
matching tuple to be posted
- If there were more
than one tuple (Jims has multiple salary
records), then returns an arbitrary one.
- read = in but without the
removal of the tuple
Example
- out("KEY",
"R")
- would post a key to resource
"R"
- in("KEY",
"R")
- would consume one key for
"R"
if no keys available would wait for one
-
NOTE: that
only one process will succeed to "in" a
given tuple
so synchronization is achieved
-
NOTE: a
process can post more than one key to a resource
allowing parallel access to that resource (the max
number of processes in a video conference)
- in("KEY", ?
anyResource)
- would get key to anyResource
posted
if more than one key, gets one arbitrarily
- in(? anyThing, "R")
- would get any associated with
resource "R"
- in(?x, ?y)
- would get any 2-tuple of type
of x and y (i.e. if x and y are integers, returns an
order pair of integers)
Accessing TUPLE Space
Can use the signature and values of
the fields to partition the tuple space
- limits search to a partition
- different partitions can be on
different processors
Thus a 2-tuple of integers would be
in a different partition than a 3-tuple of integers and
2-tuple of real numbers.
If first field is a literal string
(the name of the tuple) then the tuple space can be further
partitioned.
In fact any field if mostly used as
a literal in a query can be used to partition or to hash the
tuple space.
Examples
out("EmployeeRecord",
"Jim", 3, salary)
would identify this as an
"EmployeeRecord" which could have its own
partition.
Furthermore, "Jim" could
be used as a hash field into this partition (assuming that
most "out" commands on this record use a literal
string to retrieve a record by employee name).
This hash function further partitions the tuple space into
hash bins which can be stored on different machines.
in("EmployeeRecord",
?who, 3, ?salary)
would return the name and salary of
employee "3" and would require a search of the
entire "EmployeeRecord" partition (unless there was
a secondary hash on employee number.
ORCA Language
Language developed along with
Amoeba project
- Somewhat Traditional (MODULA-2
like)
- type secure
- no pointers
- objects (which can be shared)
- fork (for creating processes)
Stack example
OBJECT implementation stack;
top : integer;
stack : array[integer 0..N-1] of integer;
operation push (item: integer);
begin
stack[top] := item;
top := top + 1;
end;
operation pop(): integer;
begin
guard top > 0 do
top := top - 1;
return stack[top];
od;
end;
begin
top := 0;
end;
To use
s,t : stack;
s$push(k);
Semantics of object operations
- shared among processes spawned
by parent
- atomic operations (mutually
exclusive access)
- sequentially consistent
- Guards provide a condition
synchronization
pre-condition to using the operation, enforced by
system
reminiscent of monitors
Managing Shared Objects
- Objects can be SINGLE COPY or
REPLICATED
REPLICATED is on all machines which access object
- SINGLE COPY is locked before
performing any operation
if not local uses RPC
- REPLICATED reads are done
locally
- REPLICATED writes use AMOEBA's
atomic reliable totally ordered group communications
or primary copy with two phase lock, update protocol
- Deadlocks are avoided by
totally ordering or first to primary copy.
- Compiler estimates read/write
ratio to decide SINGLE/REPLICATED
- Run time system can change
this
Copyright chris wild 1996.
For problems or questions regarding this web contact [Dr. Wild].
Last updated: November 20, 1996.