Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes.

Slides:



Advertisements
Similar presentations
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Advertisements

Systems Software.
Compiler Construction by Muhammad Bilal Zafar (AP)
CPSC Compiler Tutorial 9 Review of Compiler.
COSC 120 Computer Programming
Paradigms for Process Interaction ECEN5053 Software Engineering of Distributed Systems University of Colorado, Boulder.
Reference Book: Modern Compiler Design by Grune, Bal, Jacobs and Langendoen Wiley 2000.
Programming Languages Structure
Compiler Construction1 A Compulsory Module for Students in Computer Science Department Faculty of IT / Al – Al Bayt University First Semester 2009/2010.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
SS ZG653Second Semester, Topic Architectural Patterns Pipe and Filter.
1 Architectural Patterns Yasser Ganji Saffar
September 7, September 7, 2015September 7, 2015September 7, 2015 Azusa, CA Sheldon X. Liang Ph. D. Computer Science at Azusa Pacific University.
ICS611 Introduction to Compilers Set 1. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
Chapter 1. Introduction.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
1 Programming Languages Tevfik Koşar Lecture - II January 19 th, 2006.
Compiler course 1. Introduction. Outline Scope of the course Disciplines involved in it Abstract view for a compiler Front-end and back-end tasks Modules.
CST320 - Lec 11 Why study compilers? n n Ties lots of things you know together: –Theory (finite automata, grammars) –Data structures –Modularization –Utilization.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
CE Operating Systems Lecture 3 Overview of OS functions and structure.
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
Pipes & Filters Architecture Pattern Source: Pattern-Oriented Software Architecture, Vol. 1, Buschmann, et al.
Processes Introduction to Operating Systems: Module 3.
C o n f i d e n t i a l 1 Course: BCA Semester: III Subject Code : BC 0042 Subject Name: Operating Systems Unit number : 1 Unit Title: Overview of Operating.
1 Chapter 1 Introduction. 2 Outlines 1.1 Overview and History 1.2 What Do Compilers Do? 1.3 The Structure of a Compiler 1.4 The Syntax and Semantics of.
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
CS 460/660 Compiler Construction. Class 01 2 Why Study Compilers? Compilers are important – –Responsible for many aspects of system performance Compilers.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
Overview of Previous Lesson(s) Over View  A program must be translated into a form in which it can be executed by a computer.  The software systems.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Chapter 1 Introduction Study Goals: Master: the phases of a compiler Understand: what is a compiler Know: interpreter,compiler structure.
Software Design and Architecture SEG3202 Nour El Kadri.
Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes.
1 Compiler & its Phases Krishan Kumar Asstt. Prof. (CSE) BPRCE, Gohana.
CS223: Software Engineering
Dr. Mohamed Ramadan Saady 314ALL CH1.1 Chapter 1: Introduction to Compiling.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter – 8 Software Tools.
Engr 691 Special Topics in Engineering Science Software Architecture Spring Semester 2004 Lecture Notes.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 1 Ahmed Ezzat.
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
Hello world !!! ASCII representation of hello.c.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Pertemuan 09 Architectural Patterns Mata kuliah: T0144 – Advanced Topics in Software Engineering Tahun: 2010.
Advanced Computer Systems
Compiler Design (40-414) Main Text Book:
PRINCIPLES OF COMPILER DESIGN
Chapter 1 Introduction.
Introduction to Compiler Construction
Lexical and Syntax Analysis
CSCI-235 Micro-Computer Applications
Compiler Construction (CS-636)
Data Flow Architecture
SOFTWARE DESIGN AND ARCHITECTURE
Chapter 1 Introduction.
-by Nisarg Vasavada (Compiled*)
课程名 编译原理 Compiling Techniques
Chapter 1: Introduction to Compiling (Cont.)
Course supervisor: Lubna Siddiqui
Compiler 薛智文 TH 6 7 8, DTH Spring.
Compiler 薛智文 TH 6 7 8, DTH Spring.
CMP 131 Introduction to Computer Programming
Compiler 薛智文 M 2 3 4, DTH Spring.
Presentation transcript:

Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes

Pipes and Filters Architectural Pattern Created: 14 September 2004, Revised: 13 April 2010

Definition The Pipes and Filters architectural pattern provides a structure for systems that process a stream of data. The Pipes and Filters architectural pattern provides a structure for systems that process a stream of data. Each processing step is encapsulated in a filter component. Data are passed through pipes between adjacent filters. Recombining filters allows you to build families of related filters 1

Context Programs that must process streams of data 2

Problem Build a system that Must be built by several developers Decomposes naturally into several independent processing steps For which the requirements are likely to change 3

Forces Possible to substitute new filters for existing ones or recombine steps into different communication structure Components implementing small processing steps easier to reuse than components implementing large steps Two steps share no information if they are not adjacent Different sources of input data exist Possible to display or store final results of computation in various ways If user stores intermediate results in files, then likelihood of errors increases and file system cluttered Possible for parallel execution of steps 4

Solution Divide task into a sequence of processing steps Implement each step by filter program that consumes from its input and produces data on its output incrementally Connect output of one step as input to succeeding step by means of pipe Enable filters to execute concurrently Connect input to sequence to some data source Connect output of sequence to some data sink 5

Structure 6 Data Source Filter1 Filter2 Data Sink Pipe

Structure (cont.) Filter  Processing units of the pipeline enrich data by computing new information from input data and adding it to output data stream refine data by concentrating or extracting information from input data stream and passing only that information to output stream transform input data to new form before passing it to output stream do some combination of enrichment, refinement, and transformation  Active filter separate process or thread pulls data from the input data stream pushes the transformed data onto the output data stream  Passive filter called as a function, a pull of the output from the filter called as a procedure, a push of output data into the filter 7

Structure (cont.) Pipes  Connectors between data source and first filter, between filters, and between last filter and data sink Data source  Entity (e.g., a file or input device) that provides input data to system.  Either actively push data down pipeline or passively supply data when requested Data sink  Entity that gathers data at end of pipeline  Either actively pull data from last filter element or passively respond when requested by last filter element 8

Implementation Divide functionality into sequence of processing steps  Each step depends upon outputs of previous step and becomes filter in system Define type and format of data to be passed along each pipe Determine how to implement each pipe connection  Pipe connecting to passive filter might be implemented as direct call of adjacent filter push connection as call of downstream filter as procedure pull connection as call of upstream filter as function 9

Implementation (cont.) Design and implement filters  Active filter needs to run with its own thread of control heavyweight operating system process  having its own address space lightweight thread  sharing an address space with other threads  Passive filter not require separate thread of control  Selection of the size of the buffer large buffers use up much available memory but involve less synchronization and context-switching overhead small buffers conserve memory at the cost of increased overhead  Different processing options 10

Implementation (cont.) Design for robust handling of errors  Example: Unix program use stderr channel to report errors  Recover from errors discard bad input and resynchronize at some well-defined point later in input data. back up input to some well-defined point and restart processing, using different processing method for bad data Configure pipes-and-filters system and initiate processing  Use standardized main program to create, connect, and initiate needed pipe and filter elements of pipeline  Use end-user tool to create, connect, and initiate needed pipe and filter elements of pipeline 11

Example A retargetable compiler for programming language Source element reads program text from file (or sequence of files) as stream of characters Lexical analyzer converts stream of characters into stream of lexical tokens for language – keywords, identifiers, operators, etc. Parser recognizes sequence of tokens that conforms to language grammar and translates sequence to abstract syntax tree Semantic analyzer reads abstract syntax tree and writes appropriately augmented abstract syntax tree 12 Source Program text Lexical Analyer Parser Semantic Analyer stream/ characters lexical tokens AST … augmented AST

Example (cont.) Global optimizer reads augmented syntax tree and outputs equivalent that is more efficient in space and time usage Intermediate code generator translates augmented syntax tree to sequence of instructions for virtual machine Local optimizer converts sequence of intermediate code instructions into more efficient sequence 13 Global optimizer Intermediate code generator Local optimizer optimized AST instruction sequence for VM augmented AST … efficient sequence …

Example (cont.) Backend code generator translates sequence of virtual machine instructions into sequence for some real platform  for some hardware processor augmented by operating system and runtime library calls Assembler needed to translate symbolic instruction sequence into relocatable binary module if previous step generated assembly code Linker needed to bind separate modules with library modules to form single executable (i.e., object code) module if previous steps generated sequence of binary modules Sink element outputs resulting binary module into file 14 Backend code generator Assembler instruction sequence for RM relocatable binary module … efficient sequence Linker single executable module Sink File

Example (cont.) 15 Backend code generator Assembler instruction sequence for RM relocatable binary module … efficient sequence Linker single executable module Sink File Global optimizer Intermediate code generator Local optimizer optimized AST instruction sequence for VM augmented AST … efficient sequence … Source Program text Lexical Analyer Parser Semantic Analyer stream/ characters lexical tokens AST … augmented AST

Example (cont.) Pipeline support different variations If source code preprocessing is to be supported  Preprocessor filter inserted in front of lexical analyzer If language to be interpreted rather than translated into object code  Backend code generator (and all components after it) replaced by for virtual machine  Backend code generator (and all components after it) replaced by interpreter for virtual machine If compiler to be retargeted to different platform  Backend code generator (and assembler and linker) for new platform substituted for old one If compiler to be modified to support a different language with same lexical structure  Parser, semantic analyzer, global optimizer, and intermediate code generator replaced If a load-and-go compiler desired  File-output sink replaced by that loads executable module into main memory and starts module executing  File-output sink replaced by loader that loads executable module into main memory and starts module executing 16

Example (cont.) To make the system more efficient or convenient System of filters may directly share global state Combine adjacent active filters and replace pipe by an upstream function call or downstream procedure call Make new information available in a filter  Example: symbol table information for runtime debugging tools 17

Variants A generalization allows filters with multiple input or output pipes to be connected in any directed graph structure Restrict to directed acyclic graph structures  tee filter in Unix provides mechanism to split stream into two streams, named pipes provide mechanisms for constructing network connections, and filters with multiple input files/streams provide mechanisms for joining two streams 18 # create two named pipes mknod pipeA p mknod pipeB p # set up side chain computation #(running in the background) cat pipeA >pipeB & # set up main pipeline computation cat filename | tr -cs "[:alpha:]" "[\n*256]" \ | tr "[:upper:]" "[:lower:]" | sort | tee pipeA | uniq \ | comm pipeB | uniq cattr sort tee uniq comm uniq cat pipeA pipeB

Consequences Benefits Intermediate files unnecessary, but possible. Flexibility by filter exchange. Flexibility by recombination. Reuse of filter elements. Rapid prototyping of pipelines. Efficiency by parallel processing 19

Consequences Liabilities Sharing state information is expensive or inflexible Efficiency gain by parallel processing is often an illusion Data transformation overhead Error handling 20

References Frank Buschmann, Regine Meunier, Hans Rohnert, Peter Sommerlad, and Michael Stal. Pattern-Oriented Software Architecture: A System of Patterns, Wiley, Mary Shaw and David Garlan. Software Architecture: Perspectives on an Emerging Discipline, Prentice-Hall,

Acknowledgement 22 This work was supported by a grant from Acxiom Corporation titled “The Acxiom Laboratory for Software Architecture and Component Engineering (ALSACE).” This work was supported by a grant from Acxiom Corporation titled “The Acxiom Laboratory for Software Architecture and Component Engineering (ALSACE).”