SFDV3006 Concurrent Programming

Similar documents
SE3BB4 Section 11. Concurrent (Software) Architectures

Programmazione Avanzata e Paradigmi Ingegneria e Scienze Informatiche - UNIBO a.a 2013/2014 Lecturer: Alessandro Ricci

CA341 - Comparative Programming Languages

Java Threads. COMP 585 Noteset #2 1

Problems with Concurrency. February 19, 2014

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

Lecture 9: Lists. MIT-AITI Kenya 2005

Java SE 8 Programming

CS11 Java. Fall Lecture 7

Review: Array Initializer Lists

THREADS & CONCURRENCY

Software Architecture

Java SE 8 Programming

Chair of Software Engineering. Java and C# in depth. Carlo A. Furia, Marco Piccioni, Bertrand Meyer. Java: concurrency

An Introduction to Software Architecture By David Garlan & Mary Shaw 94

Java SE 8 Programming

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started

An Introduction to Software Architecture. David Garlan & Mary Shaw 94

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

VALLIAMMAI ENGINEERING COLLEGE

CSE 113 A. Announcements - Lab

Concurrency & Parallelism. Threads, Concurrency, and Parallelism. Multicore Processors 11/7/17

CMSC 330: Organization of Programming Languages. Threads Classic Concurrency Problems

Architectural Styles. Reid Holmes

Threads, Concurrency, and Parallelism

Chapter 3: Processes. Operating System Concepts Essentials 8 th Edition

Synchronization. Announcements. Concurrent Programs. Race Conditions. Race Conditions 11/9/17. Purpose of this lecture. A8 released today, Due: 11/21

Architectural Styles. Software Architecture Lecture 5. Copyright Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy. All rights reserved.

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

CHAPTER 3 - PROCESS CONCEPT

Embedded System Design and Modeling EE382V, Fall 2008

CPS 310 first midterm exam, 10/6/2014

Week 7. Concurrent Programming: Thread Synchronization. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

ADVANCED SOFTWARE DESIGN LECTURE 4 SOFTWARE ARCHITECTURE

Lecture 15 Pipelining & ILP Instructor: Prof. Falsafi

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 8: Semaphores, Monitors, & Condition Variables

Introduction to Programming System Design CSCI 455x (4 Units)

Synchronized Methods of Old Versions of Java

Communication Paradigms

Introduction to Concurrent Software Systems. CSCI 5828: Foundations of Software Engineering Lecture 08 09/17/2015

Input/Output Management

Program Graph. Lecture 25: Parallelism & Concurrency. Performance. What does it mean?

Software Architecture

CS193k, Stanford Handout #8. Threads 3

[Course Overview] After completing this module you are ready to: Develop Desktop applications, Networking & Multi-threaded programs in java.

The Sun s Java Certification and its Possible Role in the Joint Teaching Material

M257 Past Paper Oct 2008 Attempted Solution

Introduction to Concurrent Software Systems. CSCI 5828: Foundations of Software Engineering Lecture 12 09/29/2016

Object Oriented Programming with Java. Unit-1

Lab. Lecture 26: Concurrency & Responsiveness. Assignment. Maze Program

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

APM. Object Monitor. Object Lab. Richard Hayton & Scarlet Schwiderski

SCHEME OF COURSE WORK

Agenda. Threads. Single and Multi-threaded Processes. What is Thread. CSCI 444/544 Operating Systems Fall 2008

Synchronization Lecture 23 Fall 2017

Concurrency User Guide

7 Abstracting over the Data Type; Java Documentation; Direct Access Data Structures

Software and Programming 1

CSIS 10B Lab 2 Bags and Stacks

The Dining Philosophers Problem CMSC 330: Organization of Programming Languages

The Java Collections Framework. Chapters 7.5

Concurrent Programming

(Refer Slide Time: 01:40)

Chapter 6: Arrays. Presentation slides for. Java Software Solutions. for AP* Computer Science 3rd Edition

Processes. Operating System Concepts with Java. 4.1 Sana a University, Dr aimen

Chapter 3: Processes

CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours:

Winter Lecture 4

CS519: Computer Networks. Lecture 5, Part 1: Mar 3, 2004 Transport: UDP/TCP demux and flow control / sequencing

CITS1001 week 4 Grouping objects

CMSC 330: Organization of Programming Languages. The Dining Philosophers Problem

Chapter 6 Parallel Loops

Chapter 27 Cluster Work Queues

Internet Application Developer

11/19/2014. Arrays. Chapter 6: Arrays. Arrays. Arrays. Java Software Solutions for AP* Computer Science A 2nd Edition

Concurrency: State Models & Design Patterns

COP 4610: Introduction to Operating Systems (Spring 2014) Chapter 3: Process. Zhi Wang Florida State University

Inter-process communication (IPC)

Linda, FT-Linda, and Jini

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

Chapter 3: Processes. Operating System Concepts 9 th Edition

Computational Expression

CMSC 132: Object-Oriented Programming II. Threads in Java

ITNPBD7 Cluster Computing Spring Using Condor

CS180 Review. Recitation Week 15

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Summary Semaphores. Passing the Baton any await statement. Synchronisation code not linked to the data

Software Service Engineering

Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions

Distributed Systems/Middleware JavaSpaces

Shell scripting and system variables. HORT Lecture 5 Instructor: Kranthi Varala

CS2110: Software Development Methods. Maps and Sets in Java

CSC209 Review. Yeah! We made it!

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes

Review. CSE 143 Java. A Magical Strategy. Hash Function Example. Want to implement Sets of objects Want fast contains( ), add( )

ΠΙΝΑΚΑΣ ΠΛΑΝΟΥ ΕΚΠΑΙΔΕΥΣΗΣ

CS 151. Exceptions & Javadoc. slides available on course website. Sunday, September 9, 12

Two Phase Commit Protocol. Distributed Systems. Remote Procedure Calls (RPC) Network & Distributed Operating Systems. Network OS.

Transcription:

SFDV3006 Concurrent Programming Lecture 6 Concurrent Architecture Concurrent Architectures Software architectures identify software components and their interaction Architectures are process structures together with the way processes interact Aim to ignore the details concerned with the application Study structures that can be used in many different situations and applications Lecture 8 / Architecture 2 1

Concurrent Architectures We identify a particular architectural style Architectural styles are re-occurring patterns of components and connectors Common styles Fork join which we have in the beginning labs Filter pipelines Supervisor workers Announcer listener Each of these commonly occur in concurrent and distributed systems Lecture 8 / Architecture 3 Filter Pipelines Filters receive input value stream and transform them into output value stream Filters are connected by pipelines Redirect output of one filter to input of the next May buffer values to de-couple processes from each other Example (from UNIX) cat 1.txt 2.txt 3.txt sort more A UNIX pipe is basically a buffer that buffers bytes of data output by one filter until they are input to the next filter. Lecture 8 / Architecture 4 2

Example: Primes Sieve Aim: compute primes between 2..N Idea: Generate a stream of numbers 2..N Create one filter for each number between 2 and N that filter all the numbers that are multiples and only outputs others Leads to a filter pipeline Gen Pipe Filter Pipe Filter Lecture 8 / Architecture 5 Primes Sieve Model The diagram on the previous slide is a structure diagram that describes the high-level structure of the program Interaction between GEN and a FILTER is through a PIPE process. In software architecture, pipes are called connectors. Connectors encapsulate the interaction between components of an architecture Lecture 8 / Architecture 6 3

Java Primes Sieve Implementation Lecture 8 / Architecture 7 //Pipe.java interface Pipe { public boolean put(object obj); public Object get(); } //PipeBufferedImpl.java import java.util.*; public class PipeBuffImpl implements Pipe{ Pipe buffered implementation private List buffer = new ArrayList(); public synchronized boolean put(object obj){ return buffer.add(obj); } Is this similar to something we covered before? } public synchronized Object get() throws InterruptedException{ while(buffer.isempty()) wait(); //pipe empty - wait Object obj = buffer.remove(0); return obj; } Lecture 8 / Architecture 8 4

Applications for Pipelines Java to HTML converter: converts a Java program to HTML. We could have a filter which adds line numbers to the Java program and another filter which converts the Java source to HTML Text classification for Web pages: Problem: HTML is used for document formatting Remove all HTML tags from Web Page (HTML filter) Remove all stop words from the cleaned web page (stop word filter) The resulting text can now be submitted to some text classification software such as SVMs etc Lecture 8 / Architecture 9 Supervisor / Worker Supervisor-worker is a concurrent architecture that can be used to exploit parallel execution on multiple processors Can be applied when a computational problem can be split into a number of independent sub-problems. These independent sub-problems are called tasks. Supervisor creates tasks and puts them into a bag. A bag is connector which lets supervisor and workers interact Workers pick tasks from the bag and perform them Workers can themselves be supervisors. Lecture 8 / Architecture 10 5

Supervisor / Worker architecture Worker Worker Worker Supervisor BAG The supervisor collects results from the bag and determines when the computation has finished Each worker repetitively takes tasks from the bag, computes the result for that task and places the result in the bag This process is repeated until the supervisor signals that the computation has finished Lecture 8 / Architecture 11 Linda Tuple Spaces Linda is a set of primitive operations used to access a data structure called a tuple space. A tuple space is shared associative memory consisting of a collection of tagged records called tuples Each data tuple is of the form: ( tag, value1,value2., value n) Tuples are exchanged in tuple spaces using associative memory A tuple space can be used for implementing bag connectors Lecture 8 / Architecture 12 6

Linda tuple spaces - operations There are three basic operations for managing data tuples: out, in and rd A process deposits a tuple in a tuple space using an out operation out( tag, expr1, expr2, expr n) A process removes a tuple from the tuple space using an in operation in( tag, field1, field2,,fieldn) The arguments to an in are called a template. The process executing in blocks until the tuple space contains a tuple that matches the template and them removes it. A template matches a tuple in the following situations: the tags are identical the template and the tuple have the same number of operations The variables in the template have the same type as the corresponding values in the tuple Lecture 8 / Architecture 13 Linda Tuple space operations contd The third basic operation is rd, which is the same as in except that the tuple matching the template is not removed from the tuple space. rd( tag, field1, field2,,fieldn) rd is used to examine the contents of a tuple space without modifying it. Linda also provides non-blocking versions of in and rd called inp and rdp which return true if a matching tuple is found and return false otherwise. Lecture 8 / Architecture 14 7

Supervisor: Supervisor-Worker algorithm forall tasks do out( task, ) end forall results: in( result, ) end out( stop ) Worker: while not rdp( stop ) do in( task, ) compute result out( result, ) end Lecture 8 / Architecture 16 8

Speedup and efficiency Supervisor-Worker architecture is used for speedup and better efficiency The speedup of a parallel algorithm is defined to be the time that a sequential program takes to compute a given problem divided by the time a parallel program takes to compute the problem on N processors. Efficiency is speedup divided by the number of processors N. If a problem takes 12 seconds to compute sequentially and 4 seconds to compute on 6 processor then the speedup is 3 and efficiency is 0.5 or 50% Lecture 8 / Architecture 18 9

Announcer-Listener An example of event-based architecture The announcer announces that some event has occurred and notifies it to all the listeners that are interested in this event. The communication is between one announcer and zero or more listeners. Announcer does not know listeners Listeners do not know announcer Communication is managed by a connector called event manager Listener process indicate their interest in a particular event by registering for that event. Lecture 8 / Architecture 19 Announcer-Listener architecture Listener Announcer Event Manager Listener Listener Listener can choose to listen only to a subset of events announced by registering a pattern with the event manager Only events that match the pattern are forwarded to the listener Listeners can also announce events to another set of listeners Listeners do not have to be active processes they can be objects. Lecture 8 / Architecture 20 10

Application examples User Interface Frameworks AWT listener are ordinary objects Events are mouse clicks, button presses Event cause operations to be invoked in listeners CORBA event service Event producers are Announcers Event channels are Event Managers Event consumers are Listeners Used, for example in distributed stock tickers Lecture 8 / Architecture 21 11