CA341 - Comparative Programming Languages

Similar documents
Distributed Systems/Middleware JavaSpaces

JavaSpaces Specification

Middleware-Konzepte. Tuple Spaces. Dr. Gero Mühl

JavaSpaces technology for distributed communication and collaboration. Chih-Yao Hsieh

Linda, JavaSpaces & Jini

COMP 4905 Honours Project Winter RSpace : A Tuple Space Implementation Using RESTful Web Services


SFDV3006 Concurrent Programming

Distributed Programming in Java

Page 1. CS 194: Distributed Systems Distributed Coordination-based Systems. Coordination Systems. Taxonomy of Coordination Models

Jini Connection Technology Architecture Overview

Abstract Memory The TupleSpace

Ubiquitous Computing Summer Supporting distributed applications. Distributed Application. Operating System. Computer Computer Computer.

New and Improved: Linda in Java

Info 408 Distributed Applications Programming Exercise sheet nb. 4

The Jini architecture. Johan Petrini and Henning Sundvall

Implementing Jini Servers without Object Serialization Support

Linda, FT-Linda, and Jini

Space Exploration EECS /25

one.world Towards a System Architecture for Pervasive Computing

CS 351 Design of Large Programs Threads and Concurrency

Screen Saver Science: Realizing Distributed Parallel Computing with Jini and JavaSpaces

DISTRIBUTED OBJECTS AND REMOTE INVOCATION

Using JavaSpaces to create adaptive distributed systems

Parsing Scheme (+ (* 2 3) 1) * 1

The security mechanisms of Java

CA341 - Comparative Programming Languages

CMSC 132: Object-Oriented Programming II

Inter-process communication (IPC)

Question Points Score

CS193k, Stanford Handout #12. Threads 4 / RMI

PARALLEL PROGRAM EXECUTION SUPPORT IN THE JGRID SYSTEM

Remote Method Invocation

Relational Algebra. Note: Slides are posted on the class website, protected by a password written on the board

A Model For Describing and Executing Test Cases Using XML and Jini/JavaSpaces

Separating Access Control Policy, Enforcement, and Functionality in Extensible Systems. Robert Grimm University of Washington

Contents. Java RMI. Java RMI. Java RMI system elements. Example application processes/machines Client machine Process/Application A

CS 3305 Intro to Threads. Lecture 6

Concurrent Programming using Threads

Run-time Program Management. Hwansoo Han

Middleware-Integration of Small Devices

02 B The Java Virtual Machine

Multitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multit

Introduction & RMI Basics. CS3524 Distributed Systems Lecture 01

Chapter 5 Distributed Objects and Remote Invocation

CS455: Introduction to Distributed Systems [Spring 2019] Dept. Of Computer Science, Colorado State University

Trading Services for Distributed Enterprise Communications. Dr. Jean-Claude Franchitti. Presentation Agenda

read write take entries Space read(waiting) write

Final Score Name SOLUTION ID Extra Credit. 15% of course grade

CS 153 Lab4 and 5. Kishore Kumar Pusukuri. Kishore Kumar Pusukuri CS 153 Lab4 and 5

Distributed object component middleware I - Java RMI

CA Compiler Construction

IBD Intergiciels et Bases de Données

Jini Technology Overview

CS 455: INTRODUCTION TO DISTRIBUTED SYSTEMS [THREADS] Frequently asked questions from the previous class survey

Distributed object component middleware I - Java RMI

Need for synchronization: If threads comprise parts of our software systems, then they must communicate.

5 Distributed Objects: The Java Approach

Electronic Payment Systems (1) E-cash

Operating System Services

Remote Method Invocation. Benoît Garbinato

Page 1. Extreme Java G Session 8 - Sub-Topic 2 OMA Trading Services

Remote Method Invocation Benoît Garbinato

AC61/AT61 DATABASE MANAGEMENT SYSTEMS DEC 2013

Object Interaction. Object Interaction. Introduction. Object Interaction vs. RPCs (2)

CS 11 java track: lecture 1

Philadelphia Area Java Users' Group December 12, 2001

Arrays: Higher Dimensional Arrays. CS0007: Introduction to Computer Programming

CMSC 433 Programming Language Technologies and Paradigms. Concurrency

T NAF: Jini & EJB

The Jini Architecture Bruno Souza Java Technologist, Sun Microsystems

Distributed Databases

Remote Procedure Call

Quiz on Tuesday April 13. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 4. Java facts and questions. Things to try in Java

5.4. Events and notifications

CS 556 Distributed Systems

2 Introduction to Java. Introduction to Programming 1 1

Habanero Extreme Scale Software Research Project

Java RMI Activation: A running example We have the following classes: MyRemoteInterface: the remote interface. Client: the client that invokes a

Jini Architecture Specification

Thread Programming. Comp-303 : Programming Techniques Lecture 11. Alexandre Denault Computer Science McGill University Winter 2004

Exceptions, try - catch - finally, throws keyword. JAVA Standard Edition

Java Threads. COMP 585 Noteset #2 1

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

ECE 587 Hardware/Software Co-Design Lecture 07 Concurrency in Practice Shared Memory I

By: Abhishek Khare (SVIM - INDORE M.P)

Dynamic Adaptability of Services in Enterprise JavaBeans Architecture

EXCEPTIONS. Objectives. The try and catch Statements. Define exceptions. Use try, catch and finally statements. Describe exception categories

CS18000: Programming I

Exam Number/Code : 1Z Exam Name: Name: Java Standard Edition 6. Demo. Version : Programmer Certified Professional Exam.

Threads SPL/2010 SPL/20 1

Process. Program Vs. process. During execution, the process may be in one of the following states

<Insert Picture Here>

EXCEPTIONS. Java Programming

Sustainable Memory Use Allocation & (Implicit) Deallocation (mostly in Java)

CS159. Nathan Sprague

Introduction to Java Written by John Bell for CS 342, Spring 2018

G51PGP Programming Paradigms. Lecture 009 Concurrency, exceptions

Relational Query Languages. Preliminaries. Formal Relational Query Languages. Example Schema, with table contents. Relational Algebra

LINDA. The eval operation resembles out, except that it creates an active tuple. For example, if fcn is a function, then

Transcription:

CA341 - Comparative Programming Languages David Sinclair There are 3 common memory models: RAM Random Access Memory is the most common memory model. In programming language terms, this means that variables are represented by an identifier that maps to the physical address of the variable in RAM. Stack All variables are held in the stack. Operators take their operands from the stack and push their result back onto the stack. For example, the ADD operator takes the top 2 items from the stack, adds them together and pushes the result into the stack. This model is used in the JVM.

(2) Associative This is also known as Content Addressable Memory. Typically data is stored in tuples (an ordered set of data items) and memory is addressed by the contents of the tuple. This form of memory is used in specific environments where memory is either outside the processor s address space or where the data is constantly being moved for optimisation purposes. Classic examples of this are databases and distributed processing. Associative Memory is also used in caches, artificial neural networks and data compression hardware. There are standards and hardware implementations of Content Addressable Memory. SQL An example of Associative Memory in Databases and the implications in terms of programming languages is SQL. In SQL, data is stored as tuples (rows) in relations (tables). For example, consider 2 relations, Student and Apply. The tuples in the Student relation contain the fields sname and sid. The tuples in the Apply relation contain the fields sid, degree and university. An SQL query to find the ID and name of the students who have applied for Computer Science ( CS ) but not Electronic Engineering ( EE ) is: select sid, sname from Student where sid in ( select sid from Apply where degree= CS ) and sid not in ( select sid from Apply where degree= EE );

SQL (2) The 2 subqueries retrieve the contents of the sid field based on the contents of the degree field in the Apply relation. The main query retrieves the sid and sname fields from the Student relation based on a subset of sid values from the Apply relation. By using Associative Memory, this allows the database engine to optimise the execution of a query by moving where data is stored. The order of the tuples in a relation, and the order of fields in the tuples can be modified at runtime without requiring the query to be changed. Tuple Spaces A tuple space is a logically shared, associatively addressed memory space into which tuples are placed and removed from. A tuple is simply an ordered collection of data elements. Tuple Spaces have been implemented in many programming languages. One of the most common implementation is Javaspaces. JavaSpaces is derived from the Linda system developed by David Gelernter. Linda is a machine independent concurrent programming concept. It, in itself, is not a language but an extension to existing sequential languages, which provides for concurrent processing. JavaSpaces extends the main ideas of Linda to the world of Java. The tuple space is replaced by a JavaSpace and the tuples are replaced by Java objects in the form of Entrys. One of the advantages of this is that the JavaSpace is aware of Java?s strong type system while retaining the associative addressing properties of Linda.

JavaSpaces Every object stored in a JavaSpace must implement the Entry interface and is a strongly typed collection of public, nonstatic, nonfinal, nontransient objects. An Entry is searched for using the same techniques and matching rules as used in the Jini lookup service. JavaSpaces is distributed with Jini development kit and is implemented by a fully-fledged service called outrigger. Since JavaSpaces uses transactions so we also have to run the transaction service mahalo. The Javaspace Interface The programming model for JavaSpaces follows a passive, type-aware version of the Linda programming model. package net. jini. space ; public interface JavaSpace public final long NO WAIT = 0; Lease write (Entry e, Transaction txn, long lease ) throws RemoteException, TransactionException ; Entry read (Entry tmpl, Transaction txn, long timeout) throws RemoteException, TransactionException, UnusableEntryException, InterruptedException ; Entry readifexists (Entry tmpl, Transaction txn, long timeout) throws RemoteException, TransactionException, UnusableEntryException, InterruptedException ; Entry take (Entry tmpl, Transaction txn, long timeout) throws RemoteException, TransactionException, UnusableEntryException, InterruptedException ;

The Javaspace Interface (2) The programming model for JavaSpaces follows a passive, type-aware version of the Linda programming model. Entry takeifexists (Entry tmpl, Transaction txn, long timeout) throws RemoteException, TransactionException, UnusableEntryException, InterruptedException ; EventRegistration notify (Entry tmpl, Transaction txn, RemoteEventListener l, long lease, MarshalledObject obj ) throws RemoteException, TransactionException ; Entry snapshot (Entry e) throws RemoteException; The write() method adds an Entry to the JavaSpace. It takes a parameter that specifies which Transaction the write() method is part of (this can be null if you do not wish the write() method to be part of any operation). The final argument specifies the requested lease duration (in milliseconds). The Javaspace Interface (3) The read() method is used to read an Entry from the JavaSpace. The read() method takes a template as an argument and returns an Entry in the JavaSpace that matches the template. If there is more than one Entry in the JavaSpace that matches the template then the JavaSpace is free to pick any matching Entry. If there is no Entry in the JavaSpace that matches the template then the read() method will wait for timeout milliseconds before returning. The readifexists() method is like the read() method except that it will block for timeout milliseconds if the only possible matching Entry is involved in a transaction, otherwise it returns immediately. The read() and readifexists() methods can also be part of a transaction.

The Javaspace Interface (4) The take() and takeifexists() methods are similar to the read() and readifexists() methods except that they remove the returned Entry from the JavaSpace. The notify() method is used to register an interest in an Entry that matches a specified template being entered into the JavaSpace. This method takes a template, a transaction, a RemoteEventListener, a requested lease duration and a MarshalledObject as arguments and returns an EventRegistration. If an Entry that matched the template is added to the JavaSpace while the lease is active then the notify() method in the RemoteEventListener is invoked. The Javaspace Interface (5) The snapshot() method provides an optimisation to improve the performance of JavaSpaces. Every time you pass an Entry as an argument of a JavaSpace method the Entry needs to be serialised. This can be a time consuming process. The snapshot() method takes an Entry and returns an Entry that can be used on future calls to the same JavaSpace. The advantage is that the returned Entry no longer needs to be serialised. This can result is a huge performance boost.

JavaSpace Diagram (c) Sun MicroSystems JavaSpaces Example import net. jini. core. entry. ; public class Message implements Entry public String content ; public Message () public Message( String content ) this. content = content ; public String tostring () return ( Message is : + content );

JavaSpaces Example (2) import net. jini. core. discovery. LookupLocator ; import net. jini. core. lookup. ; import net. jini. core. entry. Entry ; import net. jini. space. JavaSpace; import net. jini. lookup. entry. ; public class HelloWorld public static void main( String [] args ) try System. out. println ( Create Message entry ); Message msg = new Message( Hello World ); Class [] types = new Class [] JavaSpace. class ; ServiceTemplate template = new ServiceTemplate ( null, types, null ); JavaSpace space = (JavaSpace) registrar. lookup (template ); JavaSpaces Example (3) space. write (msg, null, Lease.FOREVER); Message template = new Message (); Message result = (Message) space. read(template, null,long.max VALUE); System. out. println ( result ); catch(exception e) e. printstacktrace (); System. exit (0);

Linda The original Linda programming model has operations equivalent to the JavaSpaces methods. JavaSpaces Linda write() out() read() rd() readifexists() rdp() take() in() takeifexists() inp() But Linda also has the concept of active tuples which are placed into a tuple space using the eval() operation. The eval() operation creates a thread in the tuple space that resolves the active tuple into a normal tuple. eval (find name(), calc score(), "CA341") Linda can be added to many languages; for example C-Linda is Linda implemented in a C language environment. Linda (2)