Top Banner
Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II
24

Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Dec 24, 2015

Download

Documents

Gary Newton
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Emerald - et OO-språk for distribuerte applikasjoner

Eric Jul

OMS

Professor II

Page 2: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Concurrency

• Process Concept: A thread in every object• Synchronization using classic Hoare

Monitors from his influential article

Page 3: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Process Concept

A process is a thread of execution.

Every object can have ONE process.

Process section in object constructor

Page 4: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Process section

object Ainitially … initialize stuffend initiallyprocess … do somethingend processend A

Page 5: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Process execution

After the end of the initially section, the process (if present) is started and executes in parallel with all other processes.

Page 6: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Concurrent Updates

object Aprocess m <-ba.withdraw[100]end processend A

object Bprocess m <- ba.withdraw[100]end processend B

Page 7: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Synchronization Required

Classic Monitors as described by Tony Hoare

Example: hi – ho program (synch.m)

Page 8: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Alternatives

• Semaphore – go thru example (sem.m)• Rendez-vous• Barrier

Page 9: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Distribution

• Sea of objects• Sea is divided into disjunct parts called

Nodes• An object is on one and only one Node at a

time• Each node is represented by a Node object• Locate X returns the node where X is

Page 10: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Location Primitive

• Locate X returns the node where X is (was!)

• Note that the object may already have moved to another node (actually any number of moves)

Page 11: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Mobility Primitive

Basic primitive is move X to YThe object X is moved where Y is.

More formally: The object denoted by the expression X is move to the node where the object denoted by expression Y was!

If the move cannot be done, it is ignored.

NOTHING is guaranteed – nothing may happen.

Page 12: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Strong Move: Fix

Basic primitive is fix X at YThe object X is moved where Y is & stays

there.

More formally: The object denoted by the expression X is move to the node where the object denoted by expression Y was!

Either the move happens – or it fails.

Strong guarantees; potentially expensive

Page 13: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Immutable Objects

• Immutable objects cannot change state• Examples: The integer 17• User-defined immutable objects: for

example complex numbers• Immutable objects are omnipresent• Types must be immutable to allow static

type checking

Page 14: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Immutable Objects

Immutable objects are omnipresent so moving them does nothing and ALWAYS succeeds.

Page 15: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Mobility Example

object Boss var w: Worker var n: Node n <- …find usable node

w <- Worker.create[ ]

move w to n w.DoWork[ ]end Boss

class Worker operation DoWork[ ] … work … work … end DoWorkend Worker

Page 16: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Why Mobility

• Local calls are typically 1,000 – 10,000 times faster than remote calls

• Mobility for:– performance– availability

Page 17: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Mobility and Location Concepts

locate X returns (one of) the object X’s

locations

move X to Y move the object X to the node

where Y is (or rather was)

fix X at Y as move but disregard

subsequent moves

refix X at Y as fix but for fixed objects

unfix X allow normal moves

Page 18: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Call-by-move

var B: some data object

X.F[move B]

X.F[visit B]

object X

operation F[arg:T]

loop

arg.g[…]

exit after many loops

end loop

end X

Page 19: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

How Many Calls of B?

Questions: given a normal PC enviroment, say 2 GHz CPU, 10 Mbit/s Ethernet, how many calls of a small (say 100 bytes) argument B before breakeven?

• 1• 10• 100• 1,000• 10,000• 100,000

Page 20: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Killroy

object Killroy process var myNode <- locate self var up: array.of[Nodes] up <- myNode.getNodes[] foreach n in up move self to n end foreach end processend Killroy

• Object moves itself to all available nodes• On the original MicroVAX implementation:

20 moves/second• Note: the thread (called a process in

Emerald) moves along

Page 21: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Types are Immutable Objects

Example: arrays

var ai: Array.of[Integer]

ai <- Array.of[Integer].create[]

var aai: Array.of[Array.of[Integer]]

Page 22: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Let’s look at the implementation of Array

(Switch to code…)

Page 23: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Planetlab

• World wide testbed

Page 24: Emerald - et OO-språk for distribuerte applikasjoner Eric Jul OMS Professor II.

Conclusion

Emerald is• clean OO language• fully integrated distribution facilities• has full on-the-fly mobility• a well-defined type system

Many novel implementation techniques (more talks to come!)