Linda and TupleSpaces. Prabhaker Mateti

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "Linda and TupleSpaces. Prabhaker Mateti"

Transcription

1 Linda and TupleSpaces Prabhaker Mateti

2 Linda Overview an example of Asynchronous Message Passing send never blocks (i.e., implicit infinite capacity buffering) ignores the order of send Associative abstract distributed shared memory system on heterogeneous networks Mateti CEG7370 Linda 2

3 Tuple Space A tuple is an ordered list of (possibly dissimilar) items (x, y), coordinates in a 2-d plane, both numbers (true, a, hello, (x, y)), a quadruple of dissimilars Instead of () some papers use < > Tuple Space is a collection of tuples Consider it a bag, not a set Count of occurrences matters. T # TS stands for #occurrences of T in TS Tuples are accessed associatively Tuples are equally accessible to all processes Mateti CEG7370 Linda 3

4 Linda s Primitives Four primitives added to a host prog lang out(t) output T into TS the number of T s in TS increases by 1 Atomic no processes are created eval(t) creates a process that evaluates T residual tuple is output to TS in(t) input T from TS the number of T s in TS decreases by 1 no processes are created more rd(t) abbrev of read(t) input T from TS the number of T s in TS does not change no processes are created Mateti CEG7370 Linda 4

5 Example: in(t) and inp(t) Suppose multiple processes are attempting Let T # TS stand for no. occurrences of T in TS if T # TS 1: input the tuple T T # TS decreases by 1 atomic operation if T # TS = 1: Only one process succeeds Which? Unspecified; nondeterministic if T # TS = 0: All processes wait for some process to out(t) may block for ever inp(t) a predicated in(t) if T#TS = 0, inp(t) fails but the process is not blocked if T#TS = 1, inp(t) succeeds effect is identical to in(t) process is not blocked rdp(t) Mateti CEG7370 Linda 5

6 Example: in( hi,?x, false) x declared to be an int the tuple pattern matches any tuple T provided: length of T = 3 T.1 = hi T.2 is any int T.3 = false X is then assigned that int Suppose TS = { ( hi, 2, false), ( hi, 2, false), ( hi, 35, false), ( hi, 7, false), in( hi,?x, false) inputs one of the above which? unspecified Tuple patterns may have multiple? symbols Mateti CEG7370 Linda 6

7 in(n, P2,, Pj) N an actual arg of type Name P2 Pj are actual/ formal params The values found in the matched tuple are assigned to the formals; the process then continues The withdrawal of the matched tuple is atomic. If multiples tuples match, non deterministic choice If no matching tuple exists, in( ) suspends until one becomes available, and does the above. Mateti CEG7370 Linda 7

8 Example: eval( i,i, sqrt(i)) Creates a new process(es) to evaluate each field of eval( i, i, sqrt(i)) the result is output to TS The tuple ( i, i, sqrt(i)) is known as an active tuple. Suppose i = 4 sqrt(i) is computed by the new process. Resulting tuple is ( i, 4, 2.0) known as a passive tuple can also be ( i, 4, -2.0) ( i, 4, 2.0) is output to TS Process(es) terminate(s). Bindings inherited from the eval-executing process only for names cited explicitly. Mateti CEG7370 Linda 8

9 Example: eval("q", f(x,y)) Suppose eval("q", f(x,y)) is being executed by process P0 P0 creates two new processes, say, P1 and P2. P1 evaluates Q P2 evaluates f(x,y) P0 moves on P0 does not wait for P1 to terminate P0 does not wait for P2 to terminate P0 may later on do an in( Q,?result) P2 evaluates f(x,y) in a context where f, x and y have the same values they had in P0 No bindings are inherited for any variables that happen to be free (i.e., global) in f, unless explicitly in the eval Mateti CEG7370 Linda 9

10 Linda Algorithm Design Example Given a finite bag B of numbers, as well as the size nb of the bag B, find the second largest number in B. Use p processes Assume the TS is preloaded with B: ( bi, b i ) for i: 1..nb ( size, nb) Each process inputs nb/p numbers of B Is nb % p = 0? Each process outputs the largest and the second largest it found A selected process considers these 2*p numbers and does as above Result Parallel Paradigm Mateti CEG7370 Linda 10

11 Linda Algorithm: Second Largest int firstandsecond(int nx) { int bi, fst, snd; in( bi,?bi); fst = snd = bi; for (int i = 1; i < nx; i++) { in( bi,?bi); if (bi > fst) { snd = fst; fst = bi; out( first, fst); out( second, snd); return 0; main(int argc, char *argv[]) { /* open a file, read numbers, * out( bi, bi) * out( nb, nb) * p = */ int i, nx = nb / p; /* Is nb % p = 0? */ for (i=0; i < p; i++) eval(firstandsecond(nx)); /* in( first, fst) and * in( second, snd) tuples * finish the computation */ Mateti CEG7370 Linda 11

12 Arrays and Matrices An Array (Array Name, index fields, value) ( V, 14, 123.5) ( A, 12, 18, 5, 123.5) That A is 3d you know it from your design; does not follow from the tuple Tuple elements can be tuples ( A, (12, 18, 5), 123.5) Mateti CEG7370 Linda 12

13 Linked Data Structures in Linda A Binary Tree Number the nodes: 1.. Number the root with 1 Use the number 0 for nil ( node, nodenumber, nodedata, leftchildnumber, rightchildnumber) A Directed Graph Represent it as a collection of directed edges. Number the nodes: 1.. ( edge, fromnodenumber, tonodenumber) Mateti CEG7370 Linda 13

14 More on Data Structures in Linda Binary Tree (again) A Lisp-like cons cell ( C, cons, [ A, B ]) ( B, cons, []) An atom ( A, atom, value) Undirected Graphs Similar to Directed Graphs How to ignore the direction in ( edge, fromnodenumber, tonodenumber)? Add ( edge, tonodenumber fromnodenumber) Or, use Set Representation. Mateti CEG7370 Linda 14

15 Coordinated Programming Programming = Computation + Coordination The term coordination refers to the process of building programs by gluing together processes. Unix glue operation: Pipe Coordination is managing dependencies between activities. Barrier Synchronization: Each process within some group must until all processes in the group have reached a barrier ; then all can proceed. Set up barrier: out ( barrier, n); Each process does the following: in( barrier,? val); out( barrier, val-1); rd( barrier, 0) Mateti CEG7370 Linda 15

16 RPC Clients and Servers servicearequest() { int ix, cid; typerq req; typers response; for (;;) { in ( request,?cid,?ix,?req) out ( response, cid, ix, response); a client process:: int clientid =, rqix = 0; typerq req; typers response; out ( request, clientid, ++rqix, req); in ( response, clientid, rqix,?response);

17 Dining Philosophers, Readers/Wr phil(int i) { while(1) { think (); in(in"room ticket") in("chopstick", i); in("chopstick", (i+i)%num); eat(); out("chopstick", i); out("chopstick",(i+i)%num); out("room ticket"); initialize() { int i; for (i = 0; i < Num; i++) { out("chopstick", i); eval(phil(i); if (i < (Num-1)) out("room ticket"); startread(); read; stopread(); startread() { rd("rw-head", incr("rw-tail")); rd("writers", 0); incr("active-readers"); incr("rw-head"); int incr(countername); { in(countername,?value); out(countername, value + 1); return value; /* complete the rest of the implementation of * the readers-writers */ Mateti CEG7370 Linda 17

18 Semaphores in Linda Create a semaphore named xyz whose initial value is 3. Solution: RHS Properties: Is it a semaphore satisfying the weak semaphore assumption? Load the tuple space with ( xyz ), ( xyz ), ( xyz ) P(nm) { in(nm); V(nm) { out(nm); Mateti CEG7370 Linda 18

19 Programming Paradigms Result Parallel focus on the structure of input space. Divide this into many pieces of the same structure. Solve each piece the same way Combine the sub-results into a final result Divide-and-Conquer Hadoop Agenda Of Activities A list of things to do and their order Example: Build A House Build Walls Frame the walls Plumbing Electrical Wiring Drywalls Doors, Windows Build a Drive Way Paint the House Ensemble Of Specialists Example: Build A House Carpenters Masons Electrician Plumbers Painters Master-slave Architecture These paradigms are applicable to not only Linda but other languages and systems. Mateti CEG7370 Linda 19

20 Result Parallel Generate Primes /* From Linda book, Chapter 5 */ int isprime(int me) { int p,limit,ok; limit=sqrt((double)me)+1; for (p=2; p < limit; ++p) { rd("primes,p,?ok); if (ok && (me%p == 0)) return 0; return 1; real_main() { int count = 0, i, ok; for(i=2; i <= LIMIT; ++i) eval("primes",i,isprime(i)); for(i = 2; i <= LIMIT; ++i) { rd("primes", i,?ok); if (ok) { ++count; printf( prime: %n\n, i); Mateti CEG7370 Linda 20

21 Paradigm: Agenda Parallelism /* From Linda book */ real_main(int argc, char *argv[]) { int eot,first_num,i,length, new_primes[grain],np2; int num,num_prices, num_workers, primes[max], p2[max]; num_workers = atoi(argv[1]); for (i = 0; i < num_workers; ++i) eval("worker", worker()); num_primes = init_primes(primes, p2); first_num = primes[num_primes-1] + 2; out("next task", first_num); eot = 0; /* Becomes 1 at end of table */ for (num = first_num; num < LIMIT; num += GRAIN){ in("result", num,? new_primes:length); for (i = 0; i < length; ++i, ++num_primes) { primes[num_primes] = new_primes[i]; if (!eot) { np2 = new_primes[i]*new_primes)[i]; if (np2 > LIMIT) { eot = 1; np2 = -1; out("primes", num_primes, new_primes[i], np2); /* "? int" match any int and throw out the value */ for (i = 0; i < num_workers; ++i) in("worker",?int); printf("count: %d\n", num_primes); worker() { int count, eot,i, limit, num, num_primes, ok,start; int my_primes[grain], primes[max], p2[max]; num_primes = init_primes(primes, p2); eot = 0; while(1) { in("next task",? num); if (num == -1) { out("next task", -1); return; limit = num + GRAIN; out("next task", (limit > LIMIT)? -1 : limit); if (limit > LIMIT) limit = LIMIT: start = num; for (count = 0; num < limit; num += 2) { while (!eot && num > p2[num_primes-1]) { rd("primes", num_primes,?primes[num_primes],?p2[num_primes]); if (p2[num_primes] < 0) eot = 1; else ++num_primes; for (i = 1, ok = 1; i < num_primes; ++i) { if (! num % primes[i])) { ok = 0; break ; if (num < p2[i]) break; if (ok) {my_primes[count] = num; ++count; /* Send the control process any primes found. */ out("result", start, my_primes:count); Mateti CEG7370 Linda 21

22 Paradigm: Specialist Parallelism /* From Linda book */ source() { int i, out_index=0; for (i = 5; i < LIMIT; i += 2) out("seg", 3, out_index++, i); out("seg", 3, out_index, 0); pipe_seg(prime, next, in_index) { int num, out_index=0; while(1) { in("seg", prime, in_index++,? num); if (!num) break; if (num % prime) out("seg", next, out_index++, num); out("seg", next, out_index, num); sink() { int in_index=0, num, pipe_seg(), prime=3, prime_count=2; while(1) { in("seg", prime, in_index++,?num); if (!num) break; if (num % prime) { ++prime_count; if (num*num < LIMIT) { eval("pipe seg, pipe_seg(prime,num,in_index)); prime = num; in_index = 0 printf("count: %d.\n", prime_count); real_main() { eval("source", source()); eval("sink", sink()); Mateti CEG7370 Linda 22

23 Linda Summary out(), in(), rd(), inp(), rdp() are heavier than host language computations. eval() is the heaviest of Linda primitives Nondeterminism in pattern matching Time uncoupling Communication between time-disjoint processes Can even send messages to self Distributed sharing Variables shared between disjoint processes Many implementations permit multiple tuple spaces No Security (no encapsulation) Linda is not fault-tolerant Processes are assumed to be fail-safe Beginners do this in a loop { in(?t); if notok(t) out(t); No guarantee you won t get the same T. The following can sequentialize the processes using this code block: {in(?count); out(count+1); Where most distributed languages are partially distributed in space and non-distributed in time, Linda is fully distributed in space and distributed in time as well.

24 JavaSpaces and TSpaces JavaSpaces is Linda adapted to Java net.jini.space.javaspace write( ): into a space take( ): from a space read( ): notify: Notifies a specified object when entries that match the given template are written into a space java.sun.com/developer/technical Articles/tools/JavaSpaces/ Tspaces is an IBM adaptation of Linda. TSpaces is network middleware for the new age of ubiquitous computing. TSpaces = Tuple + Database + Java write( ): into a space take( ): from a space read( ): Scan and ConsumingScan rendezvous operator, Rhonda. Tspaces Whiteboard es/ Mateti CEG7370 Linda 24

25 NetWorkSpaces open-source software package that makes it easy to use clusters from within scripting languages like Matlab, Python, and R. Nicholas Carriero and David Gelernter, How to Write Parallel Programs book, MIT Press, 1992 Tutorial on Parallel Programming with Linda Mateti CEG7370 Linda 25

26 CEG 730 Preferences Assume TS is preloaded with input data in a form that is helpful. At the end of the algorithm, TS should have only the results the preloaded input data is removed Any C-program can be embedded into C-Linda not acceptable at all Use p processes In general, you choose p so that elapsed time is minimized assuming the p processes do time-overlapped parallel computation. Is nb % p == 0? pad the input data space with dummy values that preserve the solutions Let some worker processes do more Avoid using inp() and/or rdp() because it confuses our thinking we can get better designs without them A badly used inp() can produce a livelock where a plain in() would have cause a block. Typically, we can avoid the use of inp(). Not always. Problem: Compute the number of elements in a bag B. Assume B is preloaded into TS. Solution needs inp(). Mateti CEG7370 Linda 26

27 References Sudhir Ahuja, Nicholas Carriero and David Gelernter, ``Linda and Friends,'' IEEE Computer (magazine), Vol. 19, No. 8, has an entire book. JavaSpaces,en.wikipedia.org/wiki/Tuple_spac e Andrews, Section 10.x on Linda. Yet another prime number generator. Jeremy R. Johnson, ~jjohnson/ /winter/cs676.htm Mateti CEG7370 Linda 27

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

Middleware-Konzepte. Tuple Spaces. Dr. Gero Mühl Middleware-Konzepte Tuple Spaces Dr. Gero Mühl Kommunikations- und Betriebssysteme Fakultät für Elektrotechnik und Informatik Technische Universität Berlin Agenda > Introduction > Linda Tuple Spaces >

More information

Processor speed. Concurrency Structure and Interpretation of Computer Programs. Multiple processors. Processor speed. Mike Phillips

Processor speed. Concurrency Structure and Interpretation of Computer Programs. Multiple processors. Processor speed. Mike Phillips <mpp> Processor speed 6.037 - Structure and Interpretation of Computer Programs Mike Phillips Massachusetts Institute of Technology http://en.wikipedia.org/wiki/file:transistor_count_and_moore%27s_law_-

More information

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

LINDA. The eval operation resembles out, except that it creates an active tuple. For example, if fcn is a function, then LINDA Linda is different, which is why we've put it into a separate chapter. Linda is not a programming language, but a way of extending ( in principle ) any language to include parallelism IMP13, IMP14.

More information

SFDV3006 Concurrent Programming

SFDV3006 Concurrent Programming SFDV3006 Concurrent Programming Lecture 6 Concurrent Architecture Concurrent Architectures Software architectures identify software components and their interaction Architectures are process structures

More information

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

Programmazione Avanzata e Paradigmi Ingegneria e Scienze Informatiche - UNIBO a.a 2013/2014 Lecturer: Alessandro Ricci v1.0 20140421 Programmazione Avanzata e Paradigmi Ingegneria e Scienze Informatiche - UNIBO a.a 2013/2014 Lecturer: Alessandro Ricci [module 3.1] ELEMENTS OF CONCURRENT PROGRAM DESIGN 1 STEPS IN DESIGN

More information

Inter-process communication (IPC)

Inter-process communication (IPC) Inter-process communication (IPC) We have studied IPC via shared data in main memory. Processes in separate address spaces also need to communicate. Consider system architecture both shared memory and

More information

Interprocess Communication By: Kaushik Vaghani

Interprocess Communication By: Kaushik Vaghani Interprocess Communication By: Kaushik Vaghani Background Race Condition: A situation where several processes access and manipulate the same data concurrently and the outcome of execution depends on the

More information

Process Management And Synchronization

Process Management And Synchronization Process Management And Synchronization In a single processor multiprogramming system the processor switches between the various jobs until to finish the execution of all jobs. These jobs will share the

More information

Abstract Memory The TupleSpace

Abstract Memory The TupleSpace Abstract Memory The TupleSpace Linda, JavaSpaces, Tspaces and PastSet Tuple Space Main idea: Byte ordered memory is a product of hardware development, not programmers needs Remodel memory to support the

More information

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017 CS 471 Operating Systems Yue Cheng George Mason University Fall 2017 1 Review: Sync Terminology Worksheet 2 Review: Semaphores 3 Semaphores o Motivation: Avoid busy waiting by blocking a process execution

More information

Chapter 5 Concurrency: Mutual Exclusion. and. Synchronization. Operating Systems: Internals. and. Design Principles

Chapter 5 Concurrency: Mutual Exclusion. and. Synchronization. Operating Systems: Internals. and. Design Principles Operating Systems: Internals and Design Principles Chapter 5 Concurrency: Mutual Exclusion and Synchronization Seventh Edition By William Stallings Designing correct routines for controlling concurrent

More information

CSE Traditional Operating Systems deal with typical system software designed to be:

CSE Traditional Operating Systems deal with typical system software designed to be: CSE 6431 Traditional Operating Systems deal with typical system software designed to be: general purpose running on single processor machines Advanced Operating Systems are designed for either a special

More information

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world alun@debian:~$ gcc hello.c alun@debian:~$ a.out Hello, world alun@debian:~$ gcc -o hello hello.c alun@debian:~$ hello Hello, world alun@debian:~$ 1 A Quick guide to C for Networks and Operating Systems

More information

Introduction to MapReduce. Adapted from Jimmy Lin (U. Maryland, USA)

Introduction to MapReduce. Adapted from Jimmy Lin (U. Maryland, USA) Introduction to MapReduce Adapted from Jimmy Lin (U. Maryland, USA) Motivation Overview Need for handling big data New programming paradigm Review of functional programming mapreduce uses this abstraction

More information

Threads and Parallelism in Java

Threads and Parallelism in Java Threads and Parallelism in Java Java is one of the few main stream programming languages to explicitly provide for user-programmed parallelism in the form of threads. A Java programmer may organize a program

More information

Chapter 4: Processes. Process Concept

Chapter 4: Processes. Process Concept Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server Systems 4.1 Silberschatz, Galvin and Gagne

More information

Topic 8: Lazy Evaluation

Topic 8: Lazy Evaluation Topic 8: Lazy Evaluation 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 17.1, 17.2, 17.4, 17.8, 17.23, 17.25, 17.28, 17.29 Readings: Chapter

More information

Concurrency. Chapter 5

Concurrency. Chapter 5 Concurrency 1 Chapter 5 2 Concurrency Is a fundamental concept in operating system design Processes execute interleaved in time on a single processor Creates the illusion of simultaneous execution Benefits

More information

SWARM Tutorial. Chen Chen 4/12/2012

SWARM Tutorial. Chen Chen 4/12/2012 SWARM Tutorial Chen Chen 4/12/2012 1 Outline Introduction to SWARM Programming in SWARM Atomic Operations in SWARM Parallel For Loop in SWARM 2 Outline Introduction to SWARM Programming in SWARM Atomic

More information

Distributed Systems. 21. Graph Computing Frameworks. Paul Krzyzanowski. Rutgers University. Fall 2016

Distributed Systems. 21. Graph Computing Frameworks. Paul Krzyzanowski. Rutgers University. Fall 2016 Distributed Systems 21. Graph Computing Frameworks Paul Krzyzanowski Rutgers University Fall 2016 November 21, 2016 2014-2016 Paul Krzyzanowski 1 Can we make MapReduce easier? November 21, 2016 2014-2016

More information

UNIX Input/Output Buffering

UNIX Input/Output Buffering UNIX Input/Output Buffering When a C/C++ program begins execution, the operating system environment is responsible for opening three files and providing file pointers to them: stdout standard output stderr

More information

Models of concurrency & synchronization algorithms

Models of concurrency & synchronization algorithms Models of concurrency & synchronization algorithms Lecture 3 of TDA383/DIT390 (Concurrent Programming) Carlo A. Furia Chalmers University of Technology University of Gothenburg SP3 2016/2017 Today s menu

More information

Message Passing. Frédéric Haziza Summer Department of Computer Systems Uppsala University

Message Passing. Frédéric Haziza Summer Department of Computer Systems Uppsala University Message Passing Frédéric Haziza Department of Computer Systems Uppsala University Summer 2009 MultiProcessor world - Taxonomy SIMD MIMD Message Passing Shared Memory Fine-grained Coarse-grained

More information

Reminder from last time

Reminder from last time Concurrent systems Lecture 5: Concurrency without shared data, composite operations and transactions, and serialisability DrRobert N. M. Watson 1 Reminder from last time Liveness properties Deadlock (requirements;

More information

An overview of Java, Data types and variables

An overview of Java, Data types and variables An overview of Java, Data types and variables Lecture 2 from (UNIT IV) Prepared by Mrs. K.M. Sanghavi 1 2 Hello World // HelloWorld.java: Hello World program import java.lang.*; class HelloWorld { public

More information

Scala : an LLVM-targeted Scala compiler

Scala : an LLVM-targeted Scala compiler Scala : an LLVM-targeted Scala compiler Da Liu, UNI: dl2997 Contents 1 Background 1 2 Introduction 1 3 Project Design 1 4 Language Prototype Features 2 4.1 Language Features........................................

More information

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

Two Phase Commit Protocol. Distributed Systems. Remote Procedure Calls (RPC) Network & Distributed Operating Systems. Network OS. A distributed system is... Distributed Systems "one on which I cannot get any work done because some machine I have never heard of has crashed". Loosely-coupled network connection could be different OSs,

More information

Semaphores. Mutual Exclusion. Inference Rules. Fairness: V may release a waiting process. Weakly fair, Strongly fair, or FIFO

Semaphores. Mutual Exclusion. Inference Rules. Fairness: V may release a waiting process. Weakly fair, Strongly fair, or FIFO Semaphores A shared integer variable, s, initialized to init, and manipulated only by two operations: pass (proberen): P(s) df = await(s > 0)s = s 1 1 Fairness: V may release a waiting process Weakly fair,

More information

Supporting Fault-Tolerant Parallel Programming in Linda

Supporting Fault-Tolerant Parallel Programming in Linda Supporting Fault-Tolerant Parallel Programming in Linda David E. Bakken and Richard D. Schlichting Department of Computer Science The University of Arizona Tucson, AZ 85721, USA Abstract Linda is a language

More information

30 Nov Dec Advanced School in High Performance and GRID Computing Concepts and Applications, ICTP, Trieste, Italy

30 Nov Dec Advanced School in High Performance and GRID Computing Concepts and Applications, ICTP, Trieste, Italy Advanced School in High Performance and GRID Computing Concepts and Applications, ICTP, Trieste, Italy Why serial is not enough Computing architectures Parallel paradigms Message Passing Interface How

More information

Programming Languages

Programming Languages Programming Languages Tevfik Koşar Lecture - XXVII May 2 nd, 2006 1 Roadmap Shared Memory Cigarette Smokers Problem Monitors Message Passing Cooperative Operations Synchronous and Asynchronous Sends Blocking

More information

CS 251 Intermediate Programming Java Basics

CS 251 Intermediate Programming Java Basics CS 251 Intermediate Programming Java Basics Brooke Chenoweth University of New Mexico Spring 2018 Prerequisites These are the topics that I assume that you have already seen: Variables Boolean expressions

More information

Binghamton University. CS-211 Fall Variable Scope

Binghamton University. CS-211 Fall Variable Scope Variable Scope 1 2 Scope The places in your code that can read and/or write a variable. Scope starts at the location where you declare the variable There may be holes in the scope! Scope ends at the end

More information

Determining the Fundamental Basis of Software Vulnerabilities. Larry Wagoner NSA

Determining the Fundamental Basis of Software Vulnerabilities. Larry Wagoner NSA Determining the Fundamental Basis of Software Vulnerabilities Larry Wagoner NSA Agenda Background Analogous background Matt Bishop work CWEs Tool reporting of CWEs KDM Analytics Determining the fundamental

More information

ITCS 4/5145 Parallel Computing Test 1 5:00 pm - 6:15 pm, Wednesday February 17, 2016 Solutions Name:...

ITCS 4/5145 Parallel Computing Test 1 5:00 pm - 6:15 pm, Wednesday February 17, 2016 Solutions Name:... ITCS 4/5145 Parallel Computing Test 1 5:00 pm - 6:15 pm, Wednesday February 17, 016 Solutions Name:... Answer questions in space provided below questions. Use additional paper if necessary but make sure

More information

148 PROCESSES CHAP. 2

148 PROCESSES CHAP. 2 148 PROCESSES CHAP. 2 Interprocess communication primitives can be used to solve such problems as the producer-consumer, dining philosophers, reader-writer, and sleeping barber. Even with these primitives,

More information

Two Types of Semaphores

Two Types of Semaphores Two Types of Semaphores Counting semaphore integer value can range over an unrestricted domain. Binary semaphore integer value can range only between 0 and 1; can be simpler to implement. Can implement

More information

Semaphores. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Semaphores. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University Semaphores Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3052: Introduction to Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) Synchronization

More information

Scheme. Functional Programming. Lambda Calculus. CSC 4101: Programming Languages 1. Textbook, Sections , 13.7

Scheme. Functional Programming. Lambda Calculus. CSC 4101: Programming Languages 1. Textbook, Sections , 13.7 Scheme Textbook, Sections 13.1 13.3, 13.7 1 Functional Programming Based on mathematical functions Take argument, return value Only function call, no assignment Functions are first-class values E.g., functions

More information

Chapter 7: Process Synchronization. Background. Illustration

Chapter 7: Process Synchronization. Background. Illustration Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors Synchronization in Solaris

More information

Chapter 4: Processes. Process Concept. Process State

Chapter 4: Processes. Process Concept. Process State Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server Systems 4.1 Process Concept An operating

More information

19.1. Unit 19. OpenMP Library for Parallelism

19.1. Unit 19. OpenMP Library for Parallelism 19.1 Unit 19 OpenMP Library for Parallelism 19.2 Overview of OpenMP A library or API (Application Programming Interface) for parallelism Requires compiler support (make sure the compiler you use supports

More information

Lecture 10: Multi-Object Synchronization

Lecture 10: Multi-Object Synchronization CS 422/522 Design & Implementation of Operating Systems Lecture 10: Multi-Object Synchronization Zhong Shao Dept. of Computer Science Yale University Acknowledgement: some slides are taken from previous

More information

Concurrent Programming (RIO) Lesson 9. Ch 8 [BenA 06] Messages Channels Rendezvous RPC and RMI. X=f(..); send X to B. OS kernel.

Concurrent Programming (RIO) Lesson 9. Ch 8 [BenA 06] Messages Channels Rendezvous RPC and RMI. X=f(..); send X to B. OS kernel. Lesson 9 Concurrency Control in Distributed Environment Ch 8 [BenA 06] Messages Channels Rendezvous RPC and RMI Distributed System No shared memory Communication with messages Tighly coupled systems Processes

More information

Chapter 5 Asynchronous Concurrent Execution

Chapter 5 Asynchronous Concurrent Execution Chapter 5 Asynchronous Concurrent Execution Outline 5.1 Introduction 5.2 Mutual Exclusion 5.2.1 Java Multithreading Case Study 5.2.2 Critical Sections 5.2.3 Mutual Exclusion Primitives 5.3 Implementing

More information

The Message Passing Interface (MPI): Parallelism on Multiple (Possibly Heterogeneous) CPUs

The Message Passing Interface (MPI): Parallelism on Multiple (Possibly Heterogeneous) CPUs 1 The Message Passing Interface (MPI): Parallelism on Multiple (Possibly Heterogeneous) s http://mpi-forum.org https://www.open-mpi.org/ Mike Bailey mjb@cs.oregonstate.edu Oregon State University mpi.pptx

More information

OpenMP. A parallel language standard that support both data and functional Parallelism on a shared memory system

OpenMP. A parallel language standard that support both data and functional Parallelism on a shared memory system OpenMP A parallel language standard that support both data and functional Parallelism on a shared memory system Use by system programmers more than application programmers Considered a low level primitives

More information

Resource Allocation. Pradipta De

Resource Allocation. Pradipta De Resource Allocation Pradipta De pradipta.de@sunykorea.ac.kr Outline Dining Philosophers Problem Drinking Philosophers Problem Dining Philosophers Problem f(5) 5 f(1) Each philosopher goes through, Think

More information

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

Concurrency & Parallelism. Threads, Concurrency, and Parallelism. Multicore Processors 11/7/17 Concurrency & Parallelism So far, our programs have been sequential: they do one thing after another, one thing at a. Let s start writing programs that do more than one thing at at a. Threads, Concurrency,

More information

CE221 Programming in C++ Part 1 Introduction

CE221 Programming in C++ Part 1 Introduction CE221 Programming in C++ Part 1 Introduction 06/10/2017 CE221 Part 1 1 Module Schedule There are two lectures (Monday 13.00-13.50 and Tuesday 11.00-11.50) each week in the autumn term, and a 2-hour lab

More information

Semaphore. Originally called P() and V() wait (S) { while S <= 0 ; // no-op S--; } signal (S) { S++; }

Semaphore. Originally called P() and V() wait (S) { while S <= 0 ; // no-op S--; } signal (S) { S++; } Semaphore Semaphore S integer variable Two standard operations modify S: wait() and signal() Originally called P() and V() Can only be accessed via two indivisible (atomic) operations wait (S) { while

More information

Chapter 6: Synchronization. Operating System Concepts 8 th Edition,

Chapter 6: Synchronization. Operating System Concepts 8 th Edition, Chapter 6: Synchronization, Silberschatz, Galvin and Gagne 2009 Outline Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization

More information

Interprocess Communication and Synchronization

Interprocess Communication and Synchronization Chapter 2 (Second Part) Interprocess Communication and Synchronization Slide Credits: Jonathan Walpole Andrew Tanenbaum 1 Outline Race Conditions Mutual Exclusion and Critical Regions Mutex s Test-And-Set

More information

PerlDSM: A Distributed Shared Memory System for Perl

PerlDSM: A Distributed Shared Memory System for Perl PerlDSM: A Distributed Shared Memory System for Perl Norman Matloff University of California, Davis matloff@cs.ucdavis.edu Proceedings of PDPTA 02 Updated July 19, 2002 Abstract A suite of Perl utilities

More information

Resource Sharing & Management

Resource Sharing & Management Resource Sharing & Management P.C.P Bhatt P.C.P Bhatt OS/M6/V1/2004 1 Introduction Some of the resources connected to a computer system (image processing resource) may be expensive. These resources may

More information

Process Co-ordination OPERATING SYSTEMS

Process Co-ordination OPERATING SYSTEMS OPERATING SYSTEMS Prescribed Text Book Operating System Principles, Seventh Edition By Abraham Silberschatz, Peter Baer Galvin and Greg Gagne 1 PROCESS - CONCEPT Processes executing concurrently in the

More information

Overloading, Type Classes, and Algebraic Datatypes

Overloading, Type Classes, and Algebraic Datatypes Overloading, Type Classes, and Algebraic Datatypes Delivered by Michael Pellauer Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. September 28, 2006 September 28, 2006 http://www.csg.csail.mit.edu/6.827

More information

Background. Module 6: Process Synchronization. Bounded-Buffer (Cont.) Bounded-Buffer. Background

Background. Module 6: Process Synchronization. Bounded-Buffer (Cont.) Bounded-Buffer. Background Module 6: Process Synchronization Background Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors Synchronization

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

Example. program sort; var a : array[0..10] of integer; procedure readarray; : function partition (y, z :integer) :integer; var i, j,x, v :integer; :

Example. program sort; var a : array[0..10] of integer; procedure readarray; : function partition (y, z :integer) :integer; var i, j,x, v :integer; : Runtime Environment Relationship between names and data objects (of target machine) Allocation & de-allocation is managed by run time support package Each execution of a procedure is an activation of the

More information

The Go Programming Language. Frank Roberts

The Go Programming Language. Frank Roberts The Go Programming Language Frank Roberts frank.roberts@uky.edu - C++ (1983), Java (1995), Python (1991): not modern - Java is 18 years old; how has computing changed in 10? - multi/many core - web programming

More information

SOFTWARE ARCHITECTURE 6. LISP

SOFTWARE ARCHITECTURE 6. LISP 1 SOFTWARE ARCHITECTURE 6. LISP Tatsuya Hagino hagino@sfc.keio.ac.jp slides URL https://vu5.sfc.keio.ac.jp/sa/ 2 Compiler vs Interpreter Compiler Translate programs into machine languages Compilers are

More information

Concepts Review. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++.

Concepts Review. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++. Concepts Review 1. An algorithm is a sequence of steps to solve a problem. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++. 3. A flowchart is the graphical

More information

CS 223: Data Structures and Programming Techniques. Exam 2

CS 223: Data Structures and Programming Techniques. Exam 2 CS 223: Data Structures and Programming Techniques. Exam 2 Instructor: Jim Aspnes Work alone. Do not use any notes or books. You have approximately 75 minutes to complete this exam. Please write your answers

More information

Message-Passing Computing

Message-Passing Computing Chapter 2 Slide 41þþ Message-Passing Computing Slide 42þþ Basics of Message-Passing Programming using userlevel message passing libraries Two primary mechanisms needed: 1. A method of creating separate

More information

Lecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8

Lecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8 Today... Java basics S. Bowers 1 of 8 Java main method (cont.) In Java, main looks like this: public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Q: How

More information

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : eaymanelshenawy@yahoo.com Reference

More information

Evolution of Programming Languages

Evolution of Programming Languages Evolution of Programming Languages 40's machine level raw binary 50's assembly language names for instructions and addresses very specific to each machine 60's high-level languages: Fortran, Cobol, Algol,

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

More information

Data Types. (with Examples In Haskell) COMP 524: Programming Languages Srinivas Krishnan March 22, 2011

Data Types. (with Examples In Haskell) COMP 524: Programming Languages Srinivas Krishnan March 22, 2011 Data Types (with Examples In Haskell) COMP 524: Programming Languages Srinivas Krishnan March 22, 2011 Based in part on slides and notes by Bjoern 1 Brandenburg, S. Olivier and A. Block. 1 Data Types Hardware-level:

More information

Maltepe University Computer Engineering Department. BİL 133 Algoritma ve Programlama. Chapter 8: Arrays and pointers

Maltepe University Computer Engineering Department. BİL 133 Algoritma ve Programlama. Chapter 8: Arrays and pointers Maltepe University Computer Engineering Department BİL 133 Algoritma ve Programlama Chapter 8: Arrays and pointers Basics int * ptr1, * ptr2; int a[10]; ptr1 = &a[2]; ptr2 = a; // equivalent to ptr2 =

More information

Defining Program Syntax. Chapter Two Modern Programming Languages, 2nd ed. 1

Defining Program Syntax. Chapter Two Modern Programming Languages, 2nd ed. 1 Defining Program Syntax Chapter Two Modern Programming Languages, 2nd ed. 1 Syntax And Semantics Programming language syntax: how programs look, their form and structure Syntax is defined using a kind

More information

Binghamton University. CS-211 Fall Variable Scope

Binghamton University. CS-211 Fall Variable Scope Variable Scope 1 Scope The places in your code that can read and/or write a variable. Scope starts at the location where you declare the variable There may be holes in the scope! Scope ends at the end

More information

INTRODUCTION TO HASKELL

INTRODUCTION TO HASKELL INTRODUCTION TO HASKELL PRINCIPLES OF PROGRAMMING LANGUAGES Norbert Zeh Winter 2018 Dalhousie University 1/81 HASKELL: A PURELY FUNCTIONAL PROGRAMMING LANGUAGE Functions are first-class values: Can be

More information

Concurrency: State Models & Design Patterns. Q&A Session Week 13

Concurrency: State Models & Design Patterns. Q&A Session Week 13 Concurrency: State Models & Design Patterns Q&A Session Week 13 Exercises 12 Discussion Exercise 12 - Task 1 Answer the following questions: a) What is a Software Architecture? What is its benefit? A Software

More information

CS4961 Parallel Programming. Lecture 18: Introduction to Message Passing 11/3/10. Final Project Purpose: Mary Hall November 2, 2010.

CS4961 Parallel Programming. Lecture 18: Introduction to Message Passing 11/3/10. Final Project Purpose: Mary Hall November 2, 2010. Parallel Programming Lecture 18: Introduction to Message Passing Mary Hall November 2, 2010 Final Project Purpose: - A chance to dig in deeper into a parallel programming model and explore concepts. -

More information

Lisp: Lab Information. Donald F. Ross

Lisp: Lab Information. Donald F. Ross Lisp: Lab Information Donald F. Ross General Model program source text stream What you need to write lexical analysis lexemes tokens syntax analysis is_id, is_number etc. + grammar rules + symbol table

More information

CA341 - Comparative Programming Languages

CA341 - Comparative Programming Languages CA341 - Comparative Programming Languages David Sinclair Dynamic Data Structures Generally we do not know how much data a program will have to process. There are 2 ways to handle this: Create a fixed data

More information

Introduction to Linear-Time Temporal Logic. CSE 814 Introduction to LTL

Introduction to Linear-Time Temporal Logic. CSE 814 Introduction to LTL Introduction to Linear-Time Temporal Logic CSE 814 Introduction to LTL 1 Outline Motivation for TL in general Types of properties to be expressed in TL Structures on which LTL formulas are evaluated Syntax

More information

Deadlock Prevention. CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han

Deadlock Prevention. CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han Deadlock Prevention CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han Announcements HW #3 is due Friday Feb. 25 extra office hours Thursday 1 pm - post this PA #2 assigned, due Thursday March 17 Midterm

More information

Concurrency Control in Distributed Environment

Concurrency Control in Distributed Environment Lesson 9 Concurrency Control in Distributed Environment Ch 8 [BenA 06] Messages Channels Rendezvous RPC and RMI 1 Distributed System No shared memory Communication with messages Tighly coupled systems

More information

Concurrency: Deadlock and Starvation. Chapter 6

Concurrency: Deadlock and Starvation. Chapter 6 Concurrency: Deadlock and Starvation Chapter 6 Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate with each other Involve conflicting needs for resources

More information

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade; Control Statements Control Statements All programs could be written in terms of only one of three control structures: Sequence Structure Selection Structure Repetition Structure Sequence structure The

More information

Pointers and scanf() Steven R. Bagley

Pointers and scanf() Steven R. Bagley Pointers and scanf() Steven R. Bagley Recap Programs are a series of statements Defined in functions Can call functions to alter program flow if statement can determine whether code gets run Loops can

More information

Lime: A Coordination Model and Middleware Supporting Mobility of Hosts and Agents

Lime: A Coordination Model and Middleware Supporting Mobility of Hosts and Agents Lime: A Coordination Model and Middleware Supporting Mobility of Hosts and Agents AMY L. MURPHY University of Lugano, Switzerland GIAN PIETRO PICCO Politecnico di Milano, Italy and GRUIA-CATALIN ROMAN

More information

6.092: Java for 6.170

6.092: Java for 6.170 6.092: Java for 6.170 Lucy Mendel MIT EECS MIT 6.092 IAP 2006 1 Course Staff Lucy Mendel Corey McCaffrey Rob Toscano Justin Mazzola Paluska Scott Osler Ray He Ask us for help! MIT 6.092 IAP 2006 2 Class

More information

Scala, Your Next Programming Language

Scala, Your Next Programming Language Scala, Your Next Programming Language (or if it is good enough for Twitter, it is good enough for me) WORLDCOMP 2011 By Dr. Mark C. Lewis Trinity University Disclaimer I am writing a Scala textbook that

More information

Semantic Analysis. CSE 307 Principles of Programming Languages Stony Brook University

Semantic Analysis. CSE 307 Principles of Programming Languages Stony Brook University Semantic Analysis CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Role of Semantic Analysis Syntax vs. Semantics: syntax concerns the form of a

More information

main read Identical static threads Dynamic threads with Concurrent and

main read Identical static threads Dynamic threads with Concurrent and CHAPTER 3: CONCURRENT PROCESSES AND PROGRAMMING Chapter outline Thread implementations Process models The client/server model Time services Language constructs for synchronization Concurrent programming

More information

CYES-C++: A Concurrent Extension of C++ through Compositional Mechanisms

CYES-C++: A Concurrent Extension of C++ through Compositional Mechanisms CYES-C++: A Concurrent Extension of C++ through Compositional Mechanisms Raju Pandey J. C. Browne Department of Computer Sciences The University of Texas at Austin Austin, TX 78712 fraju, browneg@cs.utexas.edu

More information

CS3360 Design and Implementation of Programming Languages Final Exam May 16, pm to 12:45pm (2 hour and 40 minutes) NAME:

CS3360 Design and Implementation of Programming Languages Final Exam May 16, pm to 12:45pm (2 hour and 40 minutes) NAME: CS3360 Design and Implementation of Programming Languages Final Exam May 16, 2013 10pm to 12:45pm (2 hour and 40 minutes) NAME: GRADE = / 140 1. Choice of Programming Languages / 25 2. Programming languages:

More information

Workshop Agenda Feb 25 th 2015

Workshop Agenda Feb 25 th 2015 Workshop Agenda Feb 25 th 2015 Time Presenter Title 09:30 T. König Talk bwhpc Concept & bwhpc-c5 - Federated User Support Activities 09:45 R. Walter Talk bwhpc architecture (bwunicluster, bwforcluster

More information

Imperative Programming Languages (IPL)

Imperative Programming Languages (IPL) Imperative Programming Languages (IPL) Definitions: The imperative (or procedural) paradigm is the closest to the structure of actual computers. It is a model that is based on moving bits around and changing

More information

Lab 7: OCaml 12:00 PM, Oct 22, 2017

Lab 7: OCaml 12:00 PM, Oct 22, 2017 CS17 Integrated Introduction to Computer Science Hughes Lab 7: OCaml 12:00 PM, Oct 22, 2017 Contents 1 Getting Started in OCaml 1 2 Pervasives Library 2 3 OCaml Basics 3 3.1 OCaml Types........................................

More information

Scheme: Data. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, Glenn G.

Scheme: Data. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, Glenn G. Scheme: Data CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, 2017 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks ggchappell@alaska.edu

More information

Lecture Topics. Announcements. Today: Concurrency (Stallings, chapter , 5.7) Next: Exam #1. Self-Study Exercise #5. Project #3 (due 9/28)

Lecture Topics. Announcements. Today: Concurrency (Stallings, chapter , 5.7) Next: Exam #1. Self-Study Exercise #5. Project #3 (due 9/28) Lecture Topics Today: Concurrency (Stallings, chapter 5.1-5.4, 5.7) Next: Exam #1 1 Announcements Self-Study Exercise #5 Project #3 (due 9/28) Project #4 (due 10/12) 2 Exam #1 Tuesday, 10/3 during lecture

More information

Parallel Programming: Background Information

Parallel Programming: Background Information 1 Parallel Programming: Background Information Mike Bailey mjb@cs.oregonstate.edu parallel.background.pptx Three Reasons to Study Parallel Programming 2 1. Increase performance: do more work in the same

More information

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed Process Management CS 537 Lecture 3: Processes Michael Swift This lecture begins a series of topics on processes, threads, and synchronization Today: processes and process management what are the OS units

More information

So what does studying PL buy me?

So what does studying PL buy me? So what does studying PL buy me? Enables you to better choose the right language but isn t that decided by libraries, standards, and my boss? Yes. Chicken-and-egg. My goal: educate tomorrow s tech leaders

More information

Arrays and Pointers in C. Alan L. Cox

Arrays and Pointers in C. Alan L. Cox Arrays and Pointers in C Alan L. Cox alc@rice.edu Objectives Be able to use arrays, pointers, and strings in C programs Be able to explain the representation of these data types at the machine level, including

More information