(C) P. H. Welch1 Chapter 4 Fundamentals of occam.

Slides:



Advertisements
Similar presentations
Programming in Occam-pi: A Tutorial By: Zain-ul-Abdin
Advertisements

1 (Review of Prerequisite Material). Processes are an abstraction of the operation of computers. So, to understand operating systems, one must have a.
Ch 7 B.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
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.
The Spin Model Checker Promela Introduction Nguyen Tuan Duc Shogo Sawai.
1 Chapter 8 Channels. 2 Concurrent Programming Constructs So far we have seen contructs based on shared memory concept (shared directly – buffer - or.
Introduction in algorithms and applications Introduction in algorithms and applications Parallel machines and architectures Parallel machines and architectures.
Concurrency in Ada Programming Languages 1 Robert Dewar.
Concurrency in Ada What concurrency is all about Relation to operating systems Language facilities vs library packages POSIX threads Ada concurrency Real.
Names and Scopes CS 351. Program Binding We should be familiar with this notion. A variable is bound to a method or current block e.g in C++: namespace.
Reasons to study concepts of PL
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Why Behavioral Wait statement Signal Timing Examples of Behavioral Descriptions –ROM.
Programming Languages Structure
1 Organization of Programming Languages-Cheng (Fall 2004) Concurrency u A PROCESS or THREAD:is a potentially-active execution context. Classic von Neumann.
Concurrency - 1 Tasking Concurrent Programming Declaration, creation, activation, termination Synchronization and communication Time and delays conditional.
OPL: Our Pattern Language. Background Design Patterns: Elements of Reusable Object-Oriented Software o Introduced patterns o Very influential book Pattern.
Fundamentals of Python: From First Programs Through Data Structures
1 Chapter 9 Spaces with LINDA. 2 Linda Linda is an experimental programming concept unlike ADA or Occam which are fully developed production-quality languages.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Parallel & Concurrent Programming: Occam Vitaliy Lvin University of Massachusetts.
Lecture 4: Parallel Programming Models. Parallel Programming Models Parallel Programming Models: Data parallelism / Task parallelism Explicit parallelism.
Abstraction IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 17, 2013 Carolyn Seaman University of Maryland, Baltimore County.
1 Chapter 5: Names, Bindings and Scopes Lionel Williams Jr. and Victoria Yan CSci 210, Advanced Software Paradigms September 26, 2010.
Comparative Programming Languages hussein suleman uct csc304s 2003.
Real-Time Software Design Yonsei University 2 nd Semester, 2014 Sanghyun Park.
High-Level Programming Languages: C++
CIS Computer Programming Logic
© P. H. Welch1 Occam 2 the Rest Chapter 10. © P. H. Welch2 {{{ occam 2 (the rest!) … ANSI/IEEE 754 floating-point … abbreviations … retyping … VAL OF.
ICOM 5995: Performance Instrumentation and Visualization for High Performance Computer Systems Lecture 7 October 16, 2002 Nayda G. Santiago.
1 Chapter 1 Parallel Machines and Computations (Fundamentals of Parallel Processing) Dr. Ranette Halverson.
Modeling Process CSCE 668Set 14: Simulations 2 May be several algorithms (processes) runs on each processor to simulate the desired communication system.
CS5204 – Operating Systems 1 Communicating Sequential Processes (CSP)
24-Aug-2015 Copyright P.H.Welch1 Managing Hard Real Times Peter Welch ( ) CPA 2015, University of Kent, 24 th. August, 2015 (28 Years Later)
Chapter 06 (Part I) Functions and an Introduction to Recursion.
Abstraction IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 17, 2013 Marie desJardins University of Maryland, Baltimore County.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
VHDL IE- CSE. What do you understand by VHDL??  VHDL stands for VHSIC (Very High Speed Integrated Circuits) Hardware Description Language.
CSC321 §6 Modelling Processes using FSP 1 Chapter 6 Modelling Processes using FSP.
1 Concurrency Architecture Types Tasks Synchronization –Semaphores –Monitors –Message Passing Concurrency in Ada Java Threads.
Modeling and Simulation Discrete-Event Simulation
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
© S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay.
Chapter 7 Selection Dept of Computer Engineering Khon Kaen University.
Introduction to Java Java Translation Program Structure
Fall 2004EE 3563 Digital Systems Design EE 3563 VHSIC Hardware Description Language  Required Reading: –These Slides –VHDL Tutorial  Very High Speed.
ICS 313: Programming Language Theory Chapter 13: Concurrency.
Distributed Programming Concepts and Notations. Inter-process Communication Synchronous Messages Asynchronous Messages Select statement Remote procedure.
Fundamentals of Parallel Computer Architecture - Chapter 71 Chapter 7 Introduction to Shared Memory Multiprocessors Yan Solihin Copyright.
Chapter Functions 6. Modular Programming 6.1 Modular Programming Modular programming: breaking a program up into smaller, manageable functions or modules.
13-1 Chapter 13 Concurrency Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads C# Threads.
© P. H. Welch1 Lego-Land ™ Chapter 5. © P. H. Welch2 … some simple networks.
CPS120: Introduction to Computer Science Variables and Constants.
1 Introduction 1. Why Data Structures? 2. What AreData Structure? 3. Phases of Software Development 4. Precondition and Postcondition 5. Examples.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Software Systems Verification and Validation Laboratory Assignment 4 Model checking Assignment date: Lab 4 Delivery date: Lab 4, 5.
55:032 - Intro. to Digital DesignPage 1 VHDL and Processes Defining Sequential Circuit Behavior.
HParC language. Background Shared memory level –Multiple separated shared memory spaces Message passing level-1 –Fast level of k separate message passing.
Lecture 4 – Function (Part 1) FTMK, UTeM – Sem /2014.
1 5-High-Performance Embedded Systems using Concurrent Process (cont.)
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
Introduction to Operating Systems
“Language Mechanism for Synchronization”
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
Some occam- Basics Co631 (Concurrency)
Computer Programming.
Introduction to the C Language
Background and Motivation
Low Level Programming Languages
Presentation transcript:

(C) P. H. Welch1 Chapter 4 Fundamentals of occam

(C) P. H. Welch2 The Influence of Language Language shapes our thoughts. Traditional programming languages (FORTRAN, Pascal, C,…) are aimed at von Neuman architectures occam is a language with parallelism at its heart

(C) P. H. Welch3 OCCAM Simple language Express (& reason about) sequential (MIMD) and parallel designs with equal fluency Enforces (hardware) discipline on parallel designs: –no shared data –point-to-point communication (i.e. no contention) Avoids many standard problems of concurrency

(C) P. H. Welch4 Simplicity of occam Parallelism Confidence with very high levels of concurrency (say > 100,000 parallel processes) Fast implementations (e.g. the Transputer imposes overhead of approx. 1  sec. when switching processes) cf: Ada  100  sec

(C) P. H. Welch5 occam Communication Synchronized Point-to-point Un-buffered Can construct (reusable) software components to give Asynchronous Broadcast (one-to-many) Multiplexed Buffered Minimal overhead – use only where necessary

(C) P. H. Welch6 Distributability of occam PAR Synchronized Point-to-point Unbuffered Inter-Transputer links follow the occam primitives and they are fast… 1.8 Mbytes/sec (T8/T4/T2) 10 Mbytes/sec (T9000) Bi-directional

(C) P. H. Welch7 A System Q R S P T

(C) P. H. Welch8 System Configuration 1 general-purpose processor n general-purpose processors m special-purpose processors any combination Software/Hardware configuration of parallel systems :-

(C) P. H. Welch9 One Processor Q R S P T

(C) P. H. Welch10 Five Processors Q R S P T

(C) P. H. Welch11 Three Processors Q R S P T

(C) P. H. Welch12 How to Balance? Other processors are not ready to send or receive; Traffic is being generated that is greater than the interprocessor bandwidth Ensure processors are not idle because :- Otherwise, adding more processors may slow you down! We need more experience before trying to build tools to help here.

(C) P. H. Welch13 Real World Autonomous Objects Independent behavior Private data Influence each other by “communication”

(C) P. H. Welch14 “Von Neumann” Machine One object One data space Simulates ** many objects sequential procedures global state info* scheduling code** * * implies loss of clarity ** implies inefficiency

(C) P. H. Welch15 “Parallel” Machine Models “real world” directly Clarity –easier to design –easier to implement –easier to validate –easier to maintain Efficiency –exploit parallel hardware –design parallel hardware

(C) P. H. Welch16 A Small System Example Two objects The behaviour of each object is simple to describe from its own point of view (“object-oriented”) The behaviour of the system is naturally described as the concurrent execution of each object The behaviour of the system is hard to describe using sequential procedural ideas

(C) P. H. Welch17 A B A produces :- 0, f(0), g(f(0)), f(g(f(0))), g(f(g(f(0)))), where :- f(n) = 1000, if n = 0 2*n,otherwise g(n) = n/3

(C) P. H. Welch18 A B B takes data in threes. For each triple (x, y, z), it prints :- x, y, z, (x + y + z)/3

(C) P. H. Welch19 Procedural Implementation? A calls B B must retain its state in global data structures Algorithm for B must be turned “inside-out” and programmed from its caller’s point-of-view (this is obscure!) (“non-object-oriented”) B calls A A must retain its state in global data structures Algorithm for A inverted to B’s point-of-view (again obscure) Master scheduler calls both A and B Symmetric solution – equal misery for all! A and B retain global state Algorithm for both A and B inverted

(C) P. H. Welch20 Parallel Implementation Object A State declared and retained locally (hidden from outside) Algorithm for A direct and simple (“object-oriented”) Object B State declared and retained locally (hidden from outside) Algorithm for B direct and simple (“object-oriented”) System Parallel instantiation of A and B (just as in the “real world”)

(C) P. H. Welch21 OCCAM … from the top

(C) P. H. Welch22 P c d b a e x y PROC P (CHAN OF INT a, b, CHAN OF BOOL c, CHAN OF BYTE d, e) INT x, y:. : Some Declarations

(C) P. H. Welch23 PROC P (CHAN OF INT a, b, CHAN OF BOOL c, CHAN OF BYTE d, e) … : P c d b a e PROC Q (CHAN OF INT a, b, c, CHAN OF BOOL d) … : Q c d b a R b a PROC R (CHAN OF BYTE a, b) … :

(C) P. H. Welch24 PROC S (CHAN OF INT a, b, CHAN OF BOOL c, CHAN OF INT d) … : S b a c d T b a c PROC T (CHAN OF BYTE a, CHAN OF BOOL b, CHAN OF BYTE c) … :

(C) P. H. Welch25 CHAN OF INT a, b, c, d: CHAN OF BYTE f, h, I, j: CHAN OF BOOL e,g: a b c e f d g j i h

(C) P. H. Welch26 a b c e f d g j Q R S P T R i h CHAN OF INT a, b, c, d: CHAN OF BYTE f, h, i, j: CHAN OF BOOL e,g: PAR P (a, d, e, f, j) Q (a, b, c, e) R (f, h) R (j, i) S (b, c, d, g) T (h, g, i) Spot the Mistake

(C) P. H. Welch27 Rendezvous P0P1 c CHAN OF INT c: PAR P0(c) P1(c)

(C) P. H. Welch28 PROC P0 (CHAN OF INT out). out ! value. P0 out P0 in PROC P1 (CHAN OF INT in). in ? x.

(C) P. H. Welch29 Synchronized Unbuffered Communication Output value down the channel out This operation does not complete until the process at the other end of the channel inputs the information Until that happens, the outputting process sleeps (possibly forever!) out ! value

(C) P. H. Welch30 Synchronized Unbuffered Communication Input the next piece of information from channel in into the variable x This operation does not complete until the process at the other end of the channel outputs the information Until that happens, the inputting process sleeps (possibly forever!) The inputting process can set “timeouts” on these inputs or choose between alternative inputs. [We will do this later] in ? x

(C) P. H. Welch31 “Rendezvous” Concept Unified concept of synchronisation + unbuffered communication. Asynchronous and buffered communication easy to construct. Incoming rendezvous selectable Hardware model: it is fast to implement Hardware model: our intuition enables us to reason about it

(C) P. H. Welch32 OCCAM... from the bottom

(C) P. H. Welch33 INT, BYTE, BOOL INT16, INT32, INT64 REAL32, REAL64 Primitive VAL INT max IS 50: VAL INT double.max is 2*max: VAL BYTE letter IS 'A': VAL []BYTE string IS "Hello*c*n": VAL [8]INT masks is [#01, #02, #04, #08, #10, #20, #40, #80] TypesTypes Constant Abbreviations [100]INT [32][32][8] BYTE []REAL64 Arrays

(C) P. H. Welch34 +, -, *, /, \ PLUS, MINUS, TIMES INT, INT  INT +, -, *, / REAL, REAL  REAL =, > INT, INT  BOOL BYTE, BYTE  BOOL REAL, REAL  BOOL =, <> *.*  BOOL STRONG TYPING OperatorsOperators

(C) P. H. Welch35 BOOL, BOOL  BOOL INT, INT  INT STRONG TYPING AND, OR NOT BOOL  BOOL /\, \/, >< ~ INT  INT > INT, INT  INT AFTER INT, INT  BOOL OperatorsOperators

(C) P. H. Welch36 Variable Declarations INT a, b: [max]INT c: [double.max]BYTE d: Timer Declarations TIMER tim: Channel Declarations CHAN OF BYTE p: [max<<2]CHAN OF INT q:

(C) P. H. Welch37 PROC fred (VAL []BYTE s, VAL BOOL mode, INT result, CHAN OF INT in, out, CHAN OF BYTE pause)... : VAL “value” parameters – local constants within the PROC body “value” parameters – local constants within the PROC body “reference” parameters Process Abstractions fred (s, mode, result) in out pause

(C) P. H. Welch38 An occam Process (Optional) Sequence of Declarations (Single) Executable Process

(C) P. H. Welch39 Primitive ProcessesAssignment a := c[2] + b Input (Synchronising) in ? a Output (Synchronising) out ! a + (2*b) STRONG TYPING STRONG TYPING

(C) P. H. Welch40 Primitive Processes TIMER (read) tim ? t Timeout (wait until specified time) tim ? AFTER t PLUS 3000Null SKIP Suspend (non-recoverable) STOP TIMER tim: INT t: TIMER tim: INT t:

(C) P. H. Welch41 Structured Processes SEQ Do these 4 processes in the sequence written SEQ in ? sum in ? x sum := sum + x out ! sum

(C) P. H. Welch42 in out xsum out in.1 in.0 cx.1 bax.0

(C) P. H. Welch43 Structured Processes PAR Do these 4 processes in parallel PAR in.0 ? x.0 in.1 ? x.1 out ! a + b c := a + (2*b) Assign/input to same var Write to same chan Read from same chan

(C) P. H. Welch44 Structured Processes IF Tests evaluated in sequence; process of the first one TRUE is executed. IF x > 0 screen ! 'p' x < 0 screen ! 'n' TRUE screen ! 'z' If all the boolean tests are FALSE, a run-time error is raised.

(C) P. H. Welch45 Structured Processes WHILE Conventional “while-loop” PROC double (CHAN OF INT in, out) WHILE TRUE INT x: SEQ in ? x out ! 2*x : in out double