1 Contents Distributed data structures Different implementations First example: bank transactions JavaSpaces concepts Replicated-worker pattern Second.

Slides:



Advertisements
Similar presentations
Operating Systems Part III: Process Management (Process Synchronization)
Advertisements

CS492B Analysis of Concurrent Programs Lock Basics Jaehyuk Huh Computer Science, KAIST.
Concurrency The need for speed. Why concurrency? Moore’s law: 1. The number of components on a chip doubles about every 18 months 2. The speed of computation.
JavaSpaces and TSpaces Theresa Tamash CDA 5937 November 4, 2002.
1 Chapter 1 Why Parallel Computing? An Introduction to Parallel Programming Peter Pacheco.
Allow. for Doubtful Accounts Other Terms Review Potpourri $100100$100100$ $200200$200200$ $300300$300300$ $400400$400400$ $
Master/Slave Architecture Pattern Source: Pattern-Oriented Software Architecture, Vol. 1, Buschmann, et al.
Computer Science 320 Parallel Computing Design Patterns.
Parallel Processing (CS526) Spring 2012(Week 6).  A parallel algorithm is a group of partitioned tasks that work with each other to solve a large problem.
Intro to Threading CS221 – 4/20/09. What we’ll cover today Finish the DOTS program Introduction to threads and multi-threading.
Reference: Message Passing Fundamentals.
1 Distributed Computing Algorithms CSCI Distributed Computing: everything not centralized many processors.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Review: Process Management Objective: –Enable fair multi-user, multiprocess computing on limited physical resources –Security and efficiency Process: running.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 31/10/2007.
Homework 2 In the docs folder of your Berkeley DB, have a careful look at documentation on how to configure BDB in main memory. In the docs folder of your.
Threads A thread is a program unit that is executed independently of other parts of the program A thread is a program unit that is executed independently.
1/11/ Atomicity & Durability Using Shadow Paging CSEP 545 Transaction Processing for E-Commerce Philip A. Bernstein Copyright ©2012 Philip A.
1 Organization of Programming Languages-Cheng (Fall 2004) Concurrency u A PROCESS or THREAD:is a potentially-active execution context. Classic von Neumann.
Pseudocode.
Ever wonder how they made STAR WARS or TOY STORY? The development of Computer Graphics is responsible for a revolution in art and media. Starting with.
Process Synchronization Ch. 4.4 – Cooperating Processes Ch. 7 – Concurrency.
Pseudocode.
4/3/ Atomicity & Durability Using Shadow Paging CSEP 545 Transaction Processing for E-Commerce Philip A. Bernstein Copyright ©2003 Philip A. Bernstein.
Transactions and Reliability. File system components Disk management Naming Reliability  What are the reliability issues in file systems? Security.
Advances in Language Design
Hadoop Ida Mele. Parallel programming Parallel programming is used to improve performance and efficiency In a parallel program, the processing is broken.
Introduction to Parallel Programming MapReduce Except where otherwise noted all portions of this work are Copyright (c) 2007 Google and are licensed under.
A Bridge to Your First Computer Science Course Prof. H.E. Dunsmore Concurrent Programming Threads Synchronization.
MapReduce: Simplified Data Processing on Large Clusters Jeffrey Dean and Sanjay Ghemawat.
Object Oriented Analysis & Design SDL Threads. Contents 2  Processes  Thread Concepts  Creating threads  Critical sections  Synchronizing threads.
DNA REASSEMBLY Using Javaspace Sung-Ho Maeung Laura Neureuter.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
School of Computer Science & Information Technology G6DICP - Lecture 9 Software Development Techniques.
April 26, CSE8380 Parallel and Distributed Processing Presentation Hong Yue Department of Computer Science & Engineering Southern Methodist University.
ECE200 – Computer Organization Chapter 9 – Multiprocessors.
Games Development 2 Concurrent Programming CO3301 Week 9.
 Distributed file systems having transaction facility need to support distributed transaction service.  A distributed transaction service is an extension.
Consider the program fragment below left. Assume that the program containing this fragment executes t1() and t2() on separate threads running on separate.
Jini Architecture Introduction System Overview An Example.
Tower of Hanoi Puzzle Jianying Yu. I. Introduction The Puzzle: Conditions: n disks and three pegs. Conditions: n disks and three pegs. Goal: Move disks.
By Jeff Dean & Sanjay Ghemawat Google Inc. OSDI 2004 Presented by : Mohit Deopujari.
Thinking in Parallel – Implementing In Code New Mexico Supercomputing Challenge in partnership with Intel Corp. and NM EPSCoR.
Project18’s Communication Drawing Design By: Camilo A. Silva BIOinformatics Summer 2008.
Finding concurrency Jakub Yaghob. Finding concurrency design space Starting point for design of a parallel solution Analysis The patterns will help identify.
Threaded Programming Lecture 1: Concepts. 2 Overview Shared memory systems Basic Concepts in Threaded Programming.
Multithreaded Programming in Java David Meredith Aalborg University.
Introduction Contain two or more CPU share common memory and peripherals. Provide greater system throughput. Multiple processor executing simultaneous.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Concurrency in Java MD. ANISUR RAHMAN. slide 2 Concurrency  Multiprogramming  Single processor runs several programs at the same time  Each program.
Reliability of Disk Systems. Reliability So far, we looked at ways to improve the performance of disk systems. Next, we will look at ways to improve the.
CSE 351 Caches. Before we start… A lot of people confused lea and mov on the midterm Totally understandable, but it’s important to make the distinction.
Lecture 5: RPC (exercises/questions). 26-Jun-16COMP28112 Lecture 52 First Six Steps of RPC TvS: Figure 4-7.
Lecture 3 – MapReduce: Implementation CSE 490h – Introduction to Distributed Computing, Spring 2009 Except as otherwise noted, the content of this presentation.
Parallel Patterns.
CSE 501N Fall ‘09 21: Introduction to Multithreading
The University of Adelaide, School of Computer Science
Object Spaces 9/22/2018.
MapReduce Simplied Data Processing on Large Clusters
Designing Parallel Algorithms (Synchronization)
Threaded Programming in Python
Subject : T0152 – Programming Language Concept
Algorithms and Problem Solving
Distributed Computing:
Lecture 6: RPC (exercises/questions)
An Introduction to Internetworking
Lecture 6: RPC (exercises/questions)
Lecture 7: RPC (exercises/questions)
MapReduce: Simplified Data Processing on Large Clusters
Presentation transcript:

1 Contents Distributed data structures Different implementations First example: bank transactions JavaSpaces concepts Replicated-worker pattern Second example: Mandelbrot set

2 Distributed data structures “A distributed data structure is a data structure that can be accessed and manipulated by multiple processes at the same time” In most distributed systems are hard to achieve Message passing (CORBA) or RMI (remote method invocation) in Java are good examples

3 Ordinary systems Ordinary systems tend to barricade data structures behind one central manager Attempting to parallelize across more than one machine faces to a bottleneck Multiple processes can’t access the data in a concurrently way

4 JavaSpace solution JavaSpaces solve this problem with a different approach Data structures are represented as collection of objects than can be independently accessed in a concurrent manner Processes no longer wait in line

5 First example Bank transactions Two bank tellers are making a deposit to the same bank account at the same time. A deposit consist in 3 different operations –Looking up –Modifying –Setting the account’s value

6 First example Problems arise in this scenario: –The bank account value is $200 –The two Bank tellers want to deposit respectively $100 and $50 –Bank teller #1 looks up the balance of $200 –Bank teller #2 looks up the balance and reads $200 too, since bank teller #1 hasn’t completed the deposit yet –Bank teller #1 performs the deposit and records a balance of $300 –Bank teller #2 performs the deposit and records a balance of $250

7 First example The bank account has been corrupted The problem occurs because updating the bank balance is not an atomic operation To solve the problem updating a shared value needs to be an atomic operation With JavaSpaces we get this atomicity “for free”

8 First Example Pseudocode for the bank transaction SharedVar template = new SharedVar(“bank account”); SharedVar result = (SharedVar) space.take(template, null, Long.MAX_VALUE); result.value = new Integer(result.value.intValue() + 100); space.write(result, null, Lease.FOREVER); The race condition can’t occur here, since only one process can “own” the bank account at the same time

9 First Example Isn’t production ready yet What append if one bank teller removes the Entry that describes the bank account and fails to return it for a program crash or a network down? Luckily there are several ways to improve our code. We’ll see that topics later…

10 JavaSpace concepts Topics that especially shine in JavaSpaces Processes involved in the computation no longer wait in line, they can work on independent pieces of data at the same time, as long as they don’t “step on each others toes” Every program written having JavaSpaces in mind should implement this concept tightly

11 JavaSpaces concepts The program data has to be broken in several (and smaller) pieces, allowing two or more processes to use the program data simultaneously

12 JavaSpace concepts: example Imagine now that two process are accessing the same array at two different locations at the same time There are two different way to do this in JavaSpaces The first is the „classic“ implementation The second is „JavaSpaces-approved“ and improves the parallelization

13 JavaSpace concepts: 1 code Pseudocode public class array1 implements Entry { public int data[]; public array1() {}; } The array is defined as a “continuous” memory area Only one process can “own” the array-Entry at the same time

14 JavaSpace concepts: 1 code The first process grabs the array, works with it and puts it back The second process can begin to work only after the end of the first process, even if they were interested in different pieces of data

15 JavaSpaces concepts: 2 code Pseudocode public class array2 implements Entry { public int data; public int offset; public array2() {} } The array is composed of several integer-Entries

16 JavaSpaces concepts: 2 code The two process work on different pieces of data at the same time The tasks don’t wait for a resource that can be shared

17 Replicated-worker pattern This pattern is designed to solve intensive computation problems in terms of smaller tasks that can be computed concurrently This pattern involves –one Master, along with –any number of workers

18 Replicated-worker pattern The Master takes a problem, divides it up into smaller tasks and deposit them into the space The workers spend their lives waiting for tasks, removing them from the space, computing them and writing the results back into the space The Master collects then the tasks’ results and combine them into a meaningful overall solution

19 Replicated-worker pattern Pseudocode for the Master: public class Master { for (int i = 0; i < totalTasks; i++) { Task task = new Task(…); space.write(task, …); } for (int i = 0; i < totalTasks; i++) { Result template = new Result(…); Result result = (Result)space.take(template, …); //… combine results }

20 Replicated-worker pattern The master iterates through all the tasks that need to be computed creating an Entry for each and writing it into the space The master iterates again, this time removing as many result entries from the space as there were tasks and combining them into some meaningful form

21 Replicated-worker pattern Pseudocode for the workers: public class Worker { for (;;) { Task template = new Task(...); Task task = (Task)space.take(template,...); Result result = compute(task); space.write(result,...); }

22 Replicated-worker pattern A worker repeatedly removes a task from the space, computes it, and writes the result of the computation back into the space, where it will be picked up by the master process

23 Second example Mandelbrot Set The problem consists mainly in the computation of an image, following a specific mathematical formula We are interested in the nature of the problem, where each pixel can be computed independently of all the rest JavaSpaces solves this problem very cleanly

24 Second example: Master The master generates a task for each scanline that need to be displayed writing it to the space It then “sleeps” waiting for the workers to do their job It finally collects the result (in whatever order it finds them) and combine them drawing the result to the screen

25 Second example: Master First iteration (building tasks) Second iteration (combine them)

26 Second example: Workers Each worker repeatedly removes a task from the space, computes the color values for the scanline represented by the task and writes the result back to the space for the master to pick up