Scope, Functions, and Storage Management

Size: px
Start display at page:

Download "Scope, Functions, and Storage Management"

Transcription

1 Scope, Functions, nd Storge Mngement Block-structured lnguges nd stck storge In-le Blocks (previous set of overheds) ctivtion records storge for locl, glol vriles First-order functions (previous set of overheds) prmeter pssg til recursion nd itertion Higher-order functions devitions from stck disciple lnguge expressiveness => implementtion complexity Higher-order functions Lnguge fetures Functions pssed s rguments Functions tht return functions from nested locks Need to mt environment of function Simpler cse Function pssed s rgument Need poter to ctivtion record higher up stck More complicted second cse Function returned s result of function cll Need to keep ctivtion record of returng function L. Dillon, CSE 452, Fll L. Dillon, CSE 452, Fll Pss function s rgument Sttic scope for function rguments vl x = ; vl x= Hello, world There re two declrtions for x. Which one is to e used for ech occurrence of x? vl x = ; : vl x= Hello, world H.. ()?? (To reduce clutter, I m not showg CLs ARs; when omitted, you my ssume CL references the AR directly ove.) L. Dillon, CSE 452, Fll How is the ccess lk for h set up? It needs to reference the AR declrg the ctul rgument But the ctul rgument cn e different for different clls to g Cnnot determe stticlly how to fd the declrg AR L. Dillon, CSE 452, Fll

2 Solution: Closures Exmple: function rgument Represent function vlue y closure, consistg of pir <l, i> where l pots to the AR declrg the function i.e. the glol referencg environment needed when the function is clled i pots to the first struction of the function code i.e., the structions to execute when the function is clled When function represented y closure is clled, Allocte new ctivtion record for the cll ( the usul mnner) Set the ccess lk the new ctivtion record to the poter l from the closure: new AR := l L. Dillon, CSE 452, Fll : vl x = ; vl x= Hello, world () To itilize function, set it to the closure formed us L. Dillon, CSE 452, Fll the current vlue of the when the function is clled this AR will e used to estlish the clled function s glol referencg environment the loction of the function code (the function code is not -le with the code for the lock) Exmple: function rgument Exmple: function rgument : vl x = ; vl x= Hello, world () : vl x = ; vl x= Hello, world () To itilize function, set it to the closure formed us the current vlue of the when the function is clled this AR will e used to estlish the clled function s glol referencg environment the loction of the function code (the function code is not -le with the code for the lock) L. Dillon, CSE 452, Fll To itilize function, set it to the closure formed us the current vlue of the when the function is clled this AR will e used to estlish the clled function s glol referencg environment the loction of the function code (the function code is not -le with the code for the lock) L. Dillon, CSE 452, Fll

3 Exmple: function rgument Exmple: function rgument : vl x = ; vl x= Hello, world () L. Dillon, CSE 452, Fll Initilize the AL the AR for the cll to g To itilize function, set it to the closure formed us use the glol environment lk (first component) of the vlue ound to g. Pss the the current functionl vlue of the rgument when the function is clled this AR will e forml used prmeter to estlish := the the ctul clled rgument function s glol referencg environment In the thexmple: loction of the function code (the function code is not -le with how the re code the ARs for the with lock) the closures for f & g found? : vl x = ; vl x= Hello, world () L. Dillon, CSE 452, Fll To itilize Trnsfer control function, to gset it to the closure formed us the current Set EP vlue to reference of the the when se of the the function new ARis clled this AR will e used Set to estlish PC to first the struction clled function s code for glol g referencg environment the loction use the of IP the (second function component) code (the function of the closure code is ound not -le to g with the code for the lock) Exmple: function rgument Exmple: function rgument : vl x = ; vl x= Hello, world () : vl x = ; vl x= Hello, world () To itilize function, set it to the closure formed us Initilize the current the AL vlue of the the AR for when the the cll function to h is clled this AR will e use used the to glol estlish environment the clled lk function s (first component) glol referencg of the closure environment ound to h. the loction of the function code (the function code is not -le with the code for the lock) L. Dillon, CSE 452, Fll To itilize Trnsfer control function, to hset it to the closure formed us the current Set EP vlue to reference of the the when se of the the function new ARis clled this AR will e used Set to estlish PC to first the struction clled function s code for glol h referencg environment the loction use the of IP the of function the closure code ound (the function to h code is not -le with the code for the lock) L. Dillon, CSE 452, Fll

4 Exmple: function rgument Summr Function rguments : vl x = ; vl x= Hello, world () L. Dillon, CSE 452, Fll To itilize function, set it to the closure formed us thehow current re vlue the of the ARs contg when the function the is dgs clled this AR will e used to estlish the clled function s glol referencg environment for y nd x found? the loction of the function code (the function code is not -le with the code for the lock) To represent function, use closure contg A lk to the glol referencg environment which to evlute the function ody A lk to the function code When function is clled AL new AR := the lk to the glol referencg environment When redy to trnsfer control: PC := the lk to the function code All ALs pot up stck (if stck grows down) My skip over ARs to fd glol vriles My still dellocte ARs usg stck (lifo) order L. Dillon, CSE 452, Fll Hrder cse: return function s result Lnguge feture Functions tht return new functions Need to mt environment of function Exmple fun compose(f,g) = (fn x => g(f x)); Function creted dynmiclly Vlues of free vriles the function ody re determed t run time function vlue is closure Exmple - dttype Trns = DEP of rel WTD of rel; - fun mk_cct_lncer(it: rel) = = = vl mt = ref it; = fun l (DEP x) = (mt :=!mt + x;!mt) = l (WTD x) = (mt :=!mt - x;!mt) = = l = - vl lnce = mk_cct_lncer(100.00); vl lnce = fn : Trns -> rel - lnce (WTD 25.00); vl it = 75.0 : rel - - mp lnce [WTD 30.0, DEP , WTD 65.00]; vl it = [45.0,245.0,180.0] : rel list L. Dillon, CSE 452, Fll L. Dillon, CSE 452, Fll

5 Exmple Exmple : fun mk_cct_lncer(it: rel) = vl mt = ref it; fun l (DEP x) = (mt :=!mt + x;!mt) l (WTD x) = (mt :=!mt - x;!mt) l vl lnce = mk_cct_lncer(100.00); lnce (WTD 25.00); lnce (DEP 10.00); lnce (DEP 15.00); fun mk_(it: rel) = : vl mt = ref it; fun l (DEP x) = (mt :=!mt + x;!mt) l (WTD x) = (mt :=!mt - x;!mt) l vl lce = mk_(100.00); lce (WTD 25.00); lce (DEP 10.00); lce (DEP 15.00); (mk_...) (lce...) mk_: lce: it: 100. mt: l: 25. L. Dillon, CSE 452, Fll L. Dillon, CSE 452, Fll Exmple Exmple fun mk_(it: rel) = : vl mt = ref it; fun l (DEP x) = (mt :=!mt + x;!mt) l (WTD x) = (mt :=!mt - x;!mt) l vl lce = mk_(100.00); lce (WTD 25.00); lce (DEP 10.00); (mk_...) (lce...) mk_: lce: it: 100. mt: l: 25. : fun mk_(it: rel) = vl mt = ref it; fun l (DEP x) = (mt :=!mt + x;!mt) l (WTD x) = (mt :=!mt - x;!mt) l vl lce = mk_(100.00); lce (WTD 25.00); lce (DEP 10.00); (mk_...) (lce...) mk_: lce: it: 100. mt: l: 25. lce (DEP 15.00); lce (DEP 15.00); L. Dillon, CSE 452, Fll L. Dillon, CSE 452, Fll

6 Exmple Exmple fun mk_(it: rel) = : vl mt = ref it; fun l (DEP x) = (mt :=!mt + x;!mt) l (WTD x) = (mt :=!mt - x;!mt) l vl lce = mk_(100.00); lce (WTD 25.00); lce (DEP 10.00); lce (DEP 15.00); (mk_...) (lce...) mk_: lce: it: 100. mt: l: fun mk_(it: rel) = : vl mt = ref it; fun l (DEP x) = (mt :=!mt + x;!mt) l (WTD x) = (mt :=!mt - x;!mt) l vl lce = mk_(100.00); lce (WTD 25.00); lce (DEP 10.00); lce (DEP 15.00); (mk_...) (lce...) mk_: lce: it: 100. mt: l: Wht would normlly hppen next nd wht is the next sttement to execute? Why cn t we use the norml procedure this sitution? L. Dillon, CSE 452, Fll L. Dillon, CSE 452, Fll Exmple Exmple : fun mk_(it: rel) = vl mt = ref it; fun l (DEP x) = (mt :=!mt + x;!mt) l (WTD x) = (mt :=!mt - x;!mt) l vl lce = mk_(100.00); lce (WTD 25.00); lce (DEP 10.00); lce (DEP 15.00); (mk_...) (lce...) mk_: lce: it: 100. mt: l: How re the ARs declrg x nd mt found? Wht ARs re on the sttic ch? the dynmic ch? Wht is the effect of executg the next two expressions? fun mk_(it: rel) = : vl mt = ref it; fun l (DEP x) = (mt :=!mt + x;!mt) l (WTD x) = (mt :=!mt - x;!mt) l vl lce = mk_(100.00); lce (WTD 25.00); lce (DEP 10.00); lce (DEP 15.00); (mk_...) (lce...) mk_: lce: it: 100. mt: l: 25. You should fish up this exmple L. Dillon, CSE 452, Fll L. Dillon, CSE 452, Fll

7 Closures We progrmmg Useful for event hndlers We progrmm function AppendButton(conter, nme, messge) { vr tn = document.creteelement(ʻuttonʼ); tn.nerhtml = nme; tn.onclick = function (evt) { lert(messge); } conter.ppendchild(tn); } Environment poter s the utton s click hndler fd the messge to disply Summr returng functions s results Use closure to mt sttic environment My need to keep ctivtion records fter return Stck (lifo) order fils! Possile stck implementtion Forget out explicit delloction Put ctivtion records on hep Invoke grge collector s needed Not s totlly crzy s is sounds L. Dillon, CSE 452, Fll L. Dillon, CSE 452, Fll Summry of scope issues Block-structured lnguge uses stck of ctivtion records Activtion records cont prmeters, locl vrs, Also poters to enclosg scope Severl different prmeter pssg mechnisms Til clls my e optimized Function prmeters/results require closures Closure environment poter is used on function cll Stck delloction my fil if function is returned from cll Closures re not needed if functions re not nested locks L. Dillon, CSE 452, Fll

Virtual Machine (Part I)

Virtual Machine (Part I) Hrvrd University CS Fll 2, Shimon Schocken Virtul Mchine (Prt I) Elements of Computing Systems Virtul Mchine I (Ch. 7) Motivtion clss clss Min Min sttic sttic x; x; function function void void min() min()

More information

From Dependencies to Evaluation Strategies

From Dependencies to Evaluation Strategies From Dependencies to Evlution Strtegies Possile strtegies: 1 let the user define the evlution order 2 utomtic strtegy sed on the dependencies: use locl dependencies to determine which ttriutes to compute

More information

Pointers and Arrays. More Pointer Examples. Pointers CS 217

Pointers and Arrays. More Pointer Examples. Pointers CS 217 Pointers nd Arrs CS 21 1 2 Pointers More Pointer Emples Wht is pointer A vrile whose vlue is the ddress of nother vrile p is pointer to vrile v Opertions &: ddress of (reference) *: indirection (dereference)

More information

cisc1110 fall 2010 lecture VI.2 call by value function parameters another call by value example:

cisc1110 fall 2010 lecture VI.2 call by value function parameters another call by value example: cisc1110 fll 2010 lecture VI.2 cll y vlue function prmeters more on functions more on cll y vlue nd cll y reference pssing strings to functions returning strings from functions vrile scope glol vriles

More information

Agenda & Reading. Class Exercise. COMPSCI 105 SS 2012 Principles of Computer Science. Arrays

Agenda & Reading. Class Exercise. COMPSCI 105 SS 2012 Principles of Computer Science. Arrays COMPSCI 5 SS Principles of Computer Science Arrys & Multidimensionl Arrys Agend & Reding Agend Arrys Creting & Using Primitive & Reference Types Assignments & Equlity Pss y Vlue & Pss y Reference Copying

More information

Introduction To Files In Pascal

Introduction To Files In Pascal Why other With Files? Introduction To Files In Pscl Too much informtion to input ll t once The informtion must be persistent (RAM is voltile) Etc. In this section of notes you will lern how to red from

More information

Lecture Overview. Knowledge-based systems in Bioinformatics, 1MB602. Procedural abstraction. The sum procedure. Integration as a procedure

Lecture Overview. Knowledge-based systems in Bioinformatics, 1MB602. Procedural abstraction. The sum procedure. Integration as a procedure Lecture Overview Knowledge-bsed systems in Bioinformtics, MB6 Scheme lecture Procedurl bstrction Higher order procedures Procedures s rguments Procedures s returned vlues Locl vribles Dt bstrction Compound

More information

CPSC 213. Polymorphism. Introduction to Computer Systems. Readings for Next Two Lectures. Back to Procedure Calls

CPSC 213. Polymorphism. Introduction to Computer Systems. Readings for Next Two Lectures. Back to Procedure Calls Redings for Next Two Lectures Text CPSC 213 Switch Sttements, Understnding Pointers - 2nd ed: 3.6.7, 3.10-1st ed: 3.6.6, 3.11 Introduction to Computer Systems Unit 1f Dynmic Control Flow Polymorphism nd

More information

Procedures vs. Functions. Procedure Call. Syntax. Activation Record for Nested Blocks. Environment. CSE 3302 Programming Languages

Procedures vs. Functions. Procedure Call. Syntax. Activation Record for Nested Blocks. Environment. CSE 3302 Programming Languages -2-3 CSE 3302 Progrmmng Lnguges Control II Procedures nd Envronments Chengk L, Wemn He Sprng Procedures vs. Functons Functon: no sde effect return vlue Functon cll: epresson Procedure: sde effect, eecuted

More information

Sample Midterm Solutions COMS W4115 Programming Languages and Translators Monday, October 12, 2009

Sample Midterm Solutions COMS W4115 Programming Languages and Translators Monday, October 12, 2009 Deprtment of Computer cience Columbi University mple Midterm olutions COM W4115 Progrmming Lnguges nd Trnsltors Mondy, October 12, 2009 Closed book, no ids. ch question is worth 20 points. Question 5(c)

More information

Memory Management Functions

Memory Management Functions Meory Mngeent Functions Chpter 9 Meory Mngeent Process of binding vlues to eory loctions Vlues y be sttic or dynic Vlues re ssigned t different plces Sttic eory Run-tie stck Hep 1 Meory Mngeent Sttic Meory

More information

- 2 U NIX FILES 1. Explin different file types vilble in UNIX or P OSIX s ystem. ( 08 mrks) ( My-08/Dec-08/My-10/My- 12) 2. Wht is n API? How is it di

- 2 U NIX FILES 1. Explin different file types vilble in UNIX or P OSIX s ystem. ( 08 mrks) ( My-08/Dec-08/My-10/My- 12) 2. Wht is n API? How is it di -1 I NTRODUCTION 1. Wht is posix stndrd? Explin different subset of posix stndrd. Write structure of progrm to filter out non- p osix complint codes from user progrm. ( 06 mrks) ( Dec- 2010). 2. W rite

More information

Symbol Table management

Symbol Table management TDDD Compilers nd interpreters TDDB44 Compiler Construction Symol Tles Symol Tles in the Compiler Symol Tle mngement source progrm Leicl nlysis Syntctic nlysis Semntic nlysis nd Intermedite code gen Code

More information

Reference types and their characteristics Class Definition Constructors and Object Creation Special objects: Strings and Arrays

Reference types and their characteristics Class Definition Constructors and Object Creation Special objects: Strings and Arrays Objects nd Clsses Reference types nd their chrcteristics Clss Definition Constructors nd Object Cretion Specil objects: Strings nd Arrys OOAD 1999/2000 Cludi Niederée, Jochim W. Schmidt Softwre Systems

More information

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming Lecture 10 Evolutionry Computtion: Evolution strtegies nd genetic progrmming Evolution strtegies Genetic progrmming Summry Negnevitsky, Person Eduction, 2011 1 Evolution Strtegies Another pproch to simulting

More information

Mid-term exam. Scores. Fall term 2012 KAIST EE209 Programming Structures for EE. Thursday Oct 25, Student's name: Student ID:

Mid-term exam. Scores. Fall term 2012 KAIST EE209 Programming Structures for EE. Thursday Oct 25, Student's name: Student ID: Fll term 2012 KAIST EE209 Progrmming Structures for EE Mid-term exm Thursdy Oct 25, 2012 Student's nme: Student ID: The exm is closed book nd notes. Red the questions crefully nd focus your nswers on wht

More information

Functor (1A) Young Won Lim 8/2/17

Functor (1A) Young Won Lim 8/2/17 Copyright (c) 2016-2017 Young W. Lim. Permission is grnted to copy, distribute nd/or modify this document under the terms of the GNU Free Documenttion License, Version 1.2 or ny lter version published

More information

PARALLEL AND DISTRIBUTED COMPUTING

PARALLEL AND DISTRIBUTED COMPUTING PARALLEL AND DISTRIBUTED COMPUTING 2009/2010 1 st Semester Teste Jnury 9, 2010 Durtion: 2h00 - No extr mteril llowed. This includes notes, scrtch pper, clcultor, etc. - Give your nswers in the ville spce

More information

Functor (1A) Young Won Lim 10/5/17

Functor (1A) Young Won Lim 10/5/17 Copyright (c) 2016-2017 Young W. Lim. Permission is grnted to copy, distribute nd/or modify this document under the terms of the GNU Free Documenttion License, Version 1.2 or ny lter version published

More information

! Smaller, simpler, subcomponent of program! Provides abstraction. n hide low-level details, give high-level structure

! Smaller, simpler, subcomponent of program! Provides abstraction. n hide low-level details, give high-level structure Function Chpte 1 Functions Oiginl slides fom Gegoy Byd, Noth Colin Stte Univesity Modified slides by Chis Wilcox, Colodo Stte Univesity! Smlle, simple, subcomponent of pogm! Povides bstction n hide lo-level

More information

UNIT 11. Query Optimization

UNIT 11. Query Optimization UNIT Query Optimiztion Contents Introduction to Query Optimiztion 2 The Optimiztion Process: An Overview 3 Optimiztion in System R 4 Optimiztion in INGRES 5 Implementing the Join Opertors Wei-Png Yng,

More information

CS201 Discussion 10 DRAWTREE + TRIES

CS201 Discussion 10 DRAWTREE + TRIES CS201 Discussion 10 DRAWTREE + TRIES DrwTree First instinct: recursion As very generic structure, we could tckle this problem s follows: drw(): Find the root drw(root) drw(root): Write the line for the

More information

Discussion 1 Recap. COP4600 Discussion 2 OS concepts, System call, and Assignment 1. Questions. Questions. Outline. Outline 10/24/2010

Discussion 1 Recap. COP4600 Discussion 2 OS concepts, System call, and Assignment 1. Questions. Questions. Outline. Outline 10/24/2010 COP4600 Discussion 2 OS concepts, System cll, nd Assignment 1 TA: Hufeng Jin hj0@cise.ufl.edu Discussion 1 Recp Introduction to C C Bsic Types (chr, int, long, flot, doule, ) C Preprocessors (#include,

More information

box Boxes and Arrows 3 true 7.59 'X' An object is drawn as a box that contains its data members, for example:

box Boxes and Arrows 3 true 7.59 'X' An object is drawn as a box that contains its data members, for example: Boxes nd Arrows There re two kinds of vriles in Jv: those tht store primitive vlues nd those tht store references. Primitive vlues re vlues of type long, int, short, chr, yte, oolen, doule, nd flot. References

More information

2 Computing all Intersections of a Set of Segments Line Segment Intersection

2 Computing all Intersections of a Set of Segments Line Segment Intersection 15-451/651: Design & Anlysis of Algorithms Novemer 14, 2016 Lecture #21 Sweep-Line nd Segment Intersection lst chnged: Novemer 8, 2017 1 Preliminries The sweep-line prdigm is very powerful lgorithmic design

More information

Reducing Costs with Duck Typing. Structural

Reducing Costs with Duck Typing. Structural Reducing Costs with Duck Typing Structurl 1 Duck Typing In computer progrmming with object-oriented progrmming lnguges, duck typing is lyer of progrmming lnguge nd design rules on top of typing. Typing

More information

Today s Lecture. Basics of Logic Design: Boolean Algebra, Logic Gates. Recursive Example. Review: The C / C++ code. Recursive Example (Continued)

Today s Lecture. Basics of Logic Design: Boolean Algebra, Logic Gates. Recursive Example. Review: The C / C++ code. Recursive Example (Continued) Tod s Lecture Bsics of Logic Design: Boolen Alger, Logic Gtes Alvin R. Leeck CPS 4 Lecture 8 Homework #2 Due Ferur 3 Outline Review (sseml recursion) Building the uilding locks Logic Design Truth tles,

More information

Fig.25: the Role of LEX

Fig.25: the Role of LEX The Lnguge for Specifying Lexicl Anlyzer We shll now study how to uild lexicl nlyzer from specifiction of tokens in the form of list of regulr expressions The discussion centers round the design of n existing

More information

Outline CS 412/413. Function calls. Stack layout. Tiling a call. Two translations

Outline CS 412/413. Function calls. Stack layout. Tiling a call. Two translations CS 412/413 Introduction to Compilers nd Trnsltors Cornell University Andrew Myers Outline Implementing function clls Implementing functions Optimizing wy the pointer Dynmiclly-llocted structures strings

More information

Midterm 2 Sample solution

Midterm 2 Sample solution Nme: Instructions Midterm 2 Smple solution CMSC 430 Introduction to Compilers Fll 2012 November 28, 2012 This exm contins 9 pges, including this one. Mke sure you hve ll the pges. Write your nme on the

More information

CSCI 3130: Formal Languages and Automata Theory Lecture 12 The Chinese University of Hong Kong, Fall 2011

CSCI 3130: Formal Languages and Automata Theory Lecture 12 The Chinese University of Hong Kong, Fall 2011 CSCI 3130: Forml Lnguges nd utomt Theory Lecture 12 The Chinese University of Hong Kong, Fll 2011 ndrej Bogdnov In progrmming lnguges, uilding prse trees is significnt tsk ecuse prse trees tell us the

More information

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5 CS321 Lnguges nd Compiler Design I Winter 2012 Lecture 5 1 FINITE AUTOMATA A non-deterministic finite utomton (NFA) consists of: An input lphet Σ, e.g. Σ =,. A set of sttes S, e.g. S = {1, 3, 5, 7, 11,

More information

Outline. Tiling, formally. Expression tile as rule. Statement tiles as rules. Function calls. CS 412 Introduction to Compilers

Outline. Tiling, formally. Expression tile as rule. Statement tiles as rules. Function calls. CS 412 Introduction to Compilers CS 412 Introduction to Compilers Andrew Myers Cornell University Lectur8 Finishing genertion 9 Mr 01 Outline Tiling s syntx-directed trnsltion Implementing function clls Implementing functions Optimizing

More information

COMMON HALF YEARLY EXAMINATION DECEMBER 2018

COMMON HALF YEARLY EXAMINATION DECEMBER 2018 li.net i.net li.net i.net li.net i.net li.net i.net li.net i.net li.net i.net li.net i.net li.net i.net li.net i.net.pds.pds COMMON HALF YEARLY EXAMINATION DECEMBER 2018 STD : XI SUBJECT: COMPUTER SCIENCE

More information

Compiler-Assisted Cache Replacement

Compiler-Assisted Cache Replacement LCPC 3 Formulting The Prolem of Compiler-Assisted Cche Replcement Hongo Yng LCPC 3 Agend Bckground: Memory hierrchy, ISA with cche hints Prolem definition: How should compiler give cche hint to minimize

More information

Lists in Lisp and Scheme

Lists in Lisp and Scheme Lists in Lisp nd Scheme Lists in Lisp nd Scheme Lists re Lisp s fundmentl dt structures, ut there re others Arrys, chrcters, strings, etc. Common Lisp hs moved on from eing merely LISt Processor However,

More information

520 Principles of Programming Languages. Memory Management. Memory Management... 35: Garbage Collection

520 Principles of Programming Languages. Memory Management. Memory Management... 35: Garbage Collection Dynmic Memory Mngement 50 Principles of Progrmming Lnguges 35: Grbge Collection Christin Collberg collberg@cs.rizon.edu Deprtment of Computer Science University of Arizon The run-time system linked in

More information

COMPUTER SCIENCE 123. Foundations of Computer Science. 6. Tuples

COMPUTER SCIENCE 123. Foundations of Computer Science. 6. Tuples COMPUTER SCIENCE 123 Foundtions of Computer Science 6. Tuples Summry: This lecture introduces tuples in Hskell. Reference: Thompson Sections 5.1 2 R.L. While, 2000 3 Tuples Most dt comes with structure

More information

Coprocessor memory definition. Loic Pallardy / Arnaud Pouliquen

Coprocessor memory definition. Loic Pallardy / Arnaud Pouliquen Coprocessor memory definition Loic Pllrdy / Arnud Pouliquen Objective 2 The gol of following slides is to sum up on-going discussion in OpenAP weekly bout Remoteproc/Rpmsg memory lloction. Following proposl

More information

Page 1. Memory Allocation and Usage CSE 361S. Different free lists for different size classes

Page 1. Memory Allocation and Usage CSE 361S. Different free lists for different size classes Keeping Trck o Free Blocks Method 1: : Implicit list using lengths -- links ll blocks Memory Alloction nd Usge Method : : Explicit list mong the ree blocks using pointers within the ree blocks CSE 361S

More information

Lexical analysis, scanners. Construction of a scanner

Lexical analysis, scanners. Construction of a scanner Lexicl nlysis scnners (NB. Pges 4-5 re for those who need to refresh their knowledge of DFAs nd NFAs. These re not presented during the lectures) Construction of scnner Tools: stte utomt nd trnsition digrms.

More information

Data Flow on a Queue Machine. Bruno R. Preiss. Copyright (c) 1987 by Bruno R. Preiss, P.Eng. All rights reserved.

Data Flow on a Queue Machine. Bruno R. Preiss. Copyright (c) 1987 by Bruno R. Preiss, P.Eng. All rights reserved. Dt Flow on Queue Mchine Bruno R. Preiss 2 Outline Genesis of dt-flow rchitectures Sttic vs. dynmic dt-flow rchitectures Pseudo-sttic dt-flow execution model Some dt-flow mchines Simple queue mchine Prioritized

More information

Virtual Machine I: Stack Arithmetic

Virtual Machine I: Stack Arithmetic Virtul Mchine I: Stck Arithmetic Building Modern Computer From First Principles www.nnd2tetris.org Elements of Computing Systems, Nisn & Schocken, MIT Press, www.nnd2tetris.org, Chpter 7: Virtul Mchine

More information

Introduction to Computer Science, Shimon Schocken, IDC Herzliya. Lecture Writing Classes

Introduction to Computer Science, Shimon Schocken, IDC Herzliya. Lecture Writing Classes Introduction to Computer Science, Shimon Schocken, IDC Herzliy Lecture 5.1-5.2 Writing Clsses Writing Clsses, Shimon Schocken IDC Herzliy, www.ro2cs.com slide 1 Clsses Two viewpos on es: Client view: how

More information

CSCI 104. Rafael Ferreira da Silva. Slides adapted from: Mark Redekopp and David Kempe

CSCI 104. Rafael Ferreira da Silva. Slides adapted from: Mark Redekopp and David Kempe CSCI 0 fel Ferreir d Silv rfsilv@isi.edu Slides dpted from: Mrk edekopp nd Dvid Kempe LOG STUCTUED MEGE TEES Series Summtion eview Let n = + + + + k $ = #%& #. Wht is n? n = k+ - Wht is log () + log ()

More information

CS 340, Fall 2014 Dec 11 th /13 th Final Exam Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string.

CS 340, Fall 2014 Dec 11 th /13 th Final Exam Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string. CS 340, Fll 2014 Dec 11 th /13 th Finl Exm Nme: Note: in ll questions, the specil symol ɛ (epsilon) is used to indicte the empty string. Question 1. [5 points] Consider the following regulr expression;

More information

Stack Manipulation. Other Issues. How about larger constants? Frame Pointer. PowerPC. Alternative Architectures

Stack Manipulation. Other Issues. How about larger constants? Frame Pointer. PowerPC. Alternative Architectures Other Issues Stck Mnipultion support for procedures (Refer to section 3.6), stcks, frmes, recursion mnipulting strings nd pointers linkers, loders, memory lyout Interrupts, exceptions, system clls nd conventions

More information

Registering as a HPE Reseller. Quick Reference Guide for new Partners in Asia Pacific

Registering as a HPE Reseller. Quick Reference Guide for new Partners in Asia Pacific Registering s HPE Reseller Quick Reference Guide for new Prtners in Asi Pcific Registering s new Reseller prtner There re five min steps to e new Reseller prtner. Crete your Appliction Copyright 2017 Hewlett

More information

Lab 1 - Counter. Create a project. Add files to the project. Compile design files. Run simulation. Debug results

Lab 1 - Counter. Create a project. Add files to the project. Compile design files. Run simulation. Debug results 1 L 1 - Counter A project is collection mechnism for n HDL design under specifiction or test. Projects in ModelSim ese interction nd re useful for orgnizing files nd specifying simultion settings. The

More information

Compilers Spring 2013 PRACTICE Midterm Exam

Compilers Spring 2013 PRACTICE Midterm Exam Compilers Spring 2013 PRACTICE Midterm Exm This is full length prctice midterm exm. If you wnt to tke it t exm pce, give yourself 7 minutes to tke the entire test. Just like the rel exm, ech question hs

More information

10.5 Graphing Quadratic Functions

10.5 Graphing Quadratic Functions 0.5 Grphing Qudrtic Functions Now tht we cn solve qudrtic equtions, we wnt to lern how to grph the function ssocited with the qudrtic eqution. We cll this the qudrtic function. Grphs of Qudrtic Functions

More information

ITEC2620 Introduction to Data Structures

ITEC2620 Introduction to Data Structures ITEC0 Introduction to Dt Structures Lecture 7 Queues, Priority Queues Queues I A queue is First-In, First-Out = FIFO uffer e.g. line-ups People enter from the ck of the line People re served (exit) from

More information

Complete Coverage Path Planning of Mobile Robot Based on Dynamic Programming Algorithm Peng Zhou, Zhong-min Wang, Zhen-nan Li, Yang Li

Complete Coverage Path Planning of Mobile Robot Based on Dynamic Programming Algorithm Peng Zhou, Zhong-min Wang, Zhen-nan Li, Yang Li 2nd Interntionl Conference on Electronic & Mechnicl Engineering nd Informtion Technology (EMEIT-212) Complete Coverge Pth Plnning of Mobile Robot Bsed on Dynmic Progrmming Algorithm Peng Zhou, Zhong-min

More information

Data sharing in OpenMP

Data sharing in OpenMP Dt shring in OpenMP Polo Burgio polo.burgio@unimore.it Outline Expressing prllelism Understnding prllel threds Memory Dt mngement Dt cluses Synchroniztion Brriers, locks, criticl sections Work prtitioning

More information

CS 241. Fall 2017 Midterm Review Solutions. October 24, Bits and Bytes 1. 3 MIPS Assembler 6. 4 Regular Languages 7.

CS 241. Fall 2017 Midterm Review Solutions. October 24, Bits and Bytes 1. 3 MIPS Assembler 6. 4 Regular Languages 7. CS 241 Fll 2017 Midterm Review Solutions Octoer 24, 2017 Contents 1 Bits nd Bytes 1 2 MIPS Assemly Lnguge Progrmming 2 3 MIPS Assemler 6 4 Regulr Lnguges 7 5 Scnning 9 1 Bits nd Bytes 1. Give two s complement

More information

Real-Time Programming in Java

Real-Time Programming in Java ARTIST2 Summer School 2008 in Europe Autrns (ner Grenole), Frnce Septemer 8-12, 8 2008 Rel-Time Progrmming in Jv Rel-Time in the Age of Complex Systems Invited Speker: Dvid F. Bcon IBM Reserch 0 Clssicl

More information

Arrays as functions. Types. Multidimensional Arrays (row major, column major form) Java arrays

Arrays as functions. Types. Multidimensional Arrays (row major, column major form) Java arrays Louden Chpters 6,9 Types Dt Types nd Abstrct Dt Types 1 Arrys s functons f: U -> V (f U s ordnl type) f() rry C rrys types cn be wthout szes rry vrbles must hve fxed sze rry_mx( [], sze) // prmeters re

More information

Graphs with at most two trees in a forest building process

Graphs with at most two trees in a forest building process Grphs with t most two trees in forest uilding process rxiv:802.0533v [mth.co] 4 Fe 208 Steve Butler Mis Hmnk Mrie Hrdt Astrct Given grph, we cn form spnning forest y first sorting the edges in some order,

More information

A Formalism for Functionality Preserving System Level Transformations

A Formalism for Functionality Preserving System Level Transformations A Formlism for Functionlity Preserving System Level Trnsformtions Smr Abdi Dniel Gjski Center for Embedded Computer Systems UC Irvine Center for Embedded Computer Systems UC Irvine Irvine, CA 92697 Irvine,

More information

Some Thoughts on Grad School. Undergraduate Compilers Review and Intro to MJC. Structure of a Typical Compiler. Lexing and Parsing

Some Thoughts on Grad School. Undergraduate Compilers Review and Intro to MJC. Structure of a Typical Compiler. Lexing and Parsing Undergrdute Compilers Review nd Intro to MJC Announcements Miling list is in full swing Tody Some thoughts on grd school Finish prsing Semntic nlysis Visitor pttern for bstrct syntx trees Some Thoughts

More information

Simrad ES80. Software Release Note Introduction

Simrad ES80. Software Release Note Introduction Simrd ES80 Softwre Relese 1.3.0 Introduction This document descries the chnges introduced with the new softwre version. Product: ES80 Softwre version: 1.3.0 This softwre controls ll functionlity in the

More information

Lecture 7: Integration Techniques

Lecture 7: Integration Techniques Lecture 7: Integrtion Techniques Antiderivtives nd Indefinite Integrls. In differentil clculus, we were interested in the derivtive of given rel-vlued function, whether it ws lgeric, eponentil or logrithmic.

More information

MTH 146 Conics Supplement

MTH 146 Conics Supplement 105- Review of Conics MTH 146 Conics Supplement In this section we review conics If ou ne more detils thn re present in the notes, r through section 105 of the ook Definition: A prol is the set of points

More information

Simplifying Algebra. Simplifying Algebra. Curriculum Ready.

Simplifying Algebra. Simplifying Algebra. Curriculum Ready. Simplifying Alger Curriculum Redy www.mthletics.com This ooklet is ll out turning complex prolems into something simple. You will e le to do something like this! ( 9- # + 4 ' ) ' ( 9- + 7-) ' ' Give this

More information

MIPS I/O and Interrupt

MIPS I/O and Interrupt MIPS I/O nd Interrupt Review Floting point instructions re crried out on seprte chip clled coprocessor 1 You hve to move dt to/from coprocessor 1 to do most common opertions such s printing, clling functions,

More information

TSGS#15(02)0025. Technical Specification Group Services and System Aspects Meeting #15, Cheju Island, Korea, March 2002

TSGS#15(02)0025. Technical Specification Group Services and System Aspects Meeting #15, Cheju Island, Korea, March 2002 Technicl Specifiction Group Services nd System Aspects Meeting #15, Cheju Islnd, Kore, 11-14 Mrch 2002 TSGS#15(02)0025 Source: SA5 (Telecom Mngement) Title: 2 Rel-5 CR 32.205 & 32.215 (CS & PS chrging)

More information

How. Without. project. your. wanting. personal. Corey. by Galen E

How. Without. project. your. wanting. personal. Corey. by Galen E B or How personl Whout wnting! n by Glen E Corey SO 've built cool A show tell Get grndm tweet out World resume THERE! OUT work how? http:// Coolest locl host Se : 3000 file Ever Mybe 're se tl/users1gien1s1colindexhtml

More information

Engineer To Engineer Note

Engineer To Engineer Note Engineer To Engineer Note EE-188 Technicl Notes on using Anlog Devices' DSP components nd development tools Contct our technicl support by phone: (800) ANALOG-D or e-mil: dsp.support@nlog.com Or visit

More information

The Greedy Method. The Greedy Method

The Greedy Method. The Greedy Method Lists nd Itertors /8/26 Presenttion for use with the textook, Algorithm Design nd Applictions, y M. T. Goodrich nd R. Tmssi, Wiley, 25 The Greedy Method The Greedy Method The greedy method is generl lgorithm

More information

L2-Python-Data-Structures

L2-Python-Data-Structures L2-Python-Dt-Structures Mrch 19, 2018 1 Principl built-in types in Python (Python ) numerics: int, flot, long, complex sequences: str, unicode, list, tuple, byterry, buffer, xrnge mppings: dict files:

More information

Integration of a Scenario Service in a Multimedia Messaging System

Integration of a Scenario Service in a Multimedia Messaging System Integrtion of Scenrio Service in Multimedi Messging System Brigitte KERVELLA, Vlérie GAY nd Eric HORLAIT Université Pierre et Mrie CURIE, Institut Blise PASCAL, Lortoire MASI 4, plce Jussieu, 75252 PARIS

More information

UT1553B BCRT True Dual-port Memory Interface

UT1553B BCRT True Dual-port Memory Interface UTMC APPICATION NOTE UT553B BCRT True Dul-port Memory Interfce INTRODUCTION The UTMC UT553B BCRT is monolithic CMOS integrted circuit tht provides comprehensive MI-STD- 553B Bus Controller nd Remote Terminl

More information

Agilent Mass Hunter Software

Agilent Mass Hunter Software Agilent Mss Hunter Softwre Quick Strt Guide Use this guide to get strted with the Mss Hunter softwre. Wht is Mss Hunter Softwre? Mss Hunter is n integrl prt of Agilent TOF softwre (version A.02.00). Mss

More information

Reducing a DFA to a Minimal DFA

Reducing a DFA to a Minimal DFA Lexicl Anlysis - Prt 4 Reducing DFA to Miniml DFA Input: DFA IN Assume DFA IN never gets stuck (dd ded stte if necessry) Output: DFA MIN An equivlent DFA with the minimum numer of sttes. Hrry H. Porter,

More information

Network Interconnection: Bridging CS 571 Fall Kenneth L. Calvert All rights reserved

Network Interconnection: Bridging CS 571 Fall Kenneth L. Calvert All rights reserved Network Interconnection: Bridging CS 57 Fll 6 6 Kenneth L. Clvert All rights reserved The Prolem We know how to uild (rodcst) LANs Wnt to connect severl LANs together to overcome scling limits Recll: speed

More information

Introduction to Julia for Bioinformatics

Introduction to Julia for Bioinformatics Introduction to Juli for Bioinformtics This introduction ssumes tht you hve bsic knowledge of some scripting lnguge nd provides n exmple of the Juli syntx. Continuous Assessment Problems In this course

More information

Keeping Track of Free Blocks The course that gives CMU its Zip! Dynamic Memory Allocation II Nov 7, Allocating From Explicit Free Lists

Keeping Track of Free Blocks The course that gives CMU its Zip! Dynamic Memory Allocation II Nov 7, Allocating From Explicit Free Lists Dynmic Memory Alloction II Nov 7, 2002 clss22.ppt 15-213 The course tht gives CMU its Zip! Topics Explicit doubly-linked ree lists Segregted ree lists Grbge collection Memory-relted perils nd pitlls Keeping

More information

OUTPUT DELIVERY SYSTEM

OUTPUT DELIVERY SYSTEM Differences in ODS formtting for HTML with Proc Print nd Proc Report Lur L. M. Thornton, USDA-ARS, Animl Improvement Progrms Lortory, Beltsville, MD ABSTRACT While Proc Print is terrific tool for dt checking

More information

Scanner Termination. Multi Character Lookahead. to its physical end. Most parsers require an end of file token. Lex and Jlex automatically create an

Scanner Termination. Multi Character Lookahead. to its physical end. Most parsers require an end of file token. Lex and Jlex automatically create an Scnner Termintion A scnner reds input chrcters nd prtitions them into tokens. Wht hppens when the end of the input file is reched? It my be useful to crete n Eof pseudo-chrcter when this occurs. In Jv,

More information

Network Layer: Routing Classifications; Shortest Path Routing

Network Layer: Routing Classifications; Shortest Path Routing igitl ommuniction in the Modern World : Routing lssifictions; Shortest Pth Routing s min prolem: To get efficiently from one point to the other in dynmic environment http://.cs.huji.c.il/~com com@cs.huji.c.il

More information

12 <= rm <digit> 2 <= rm <no> 2 <= rm <no> <digit> <= rm <no> <= rm <number>

12 <= rm <digit> 2 <= rm <no> 2 <= rm <no> <digit> <= rm <no> <= rm <number> DDD16 Compilers nd Interpreters DDB44 Compiler Construction R Prsing Prt 1 R prsing concept Using prser genertor Prse ree Genertion Wht is R-prsing? eft-to-right scnning R Rigthmost derivtion in reverse

More information

Solution of Linear Algebraic Equations using the Gauss-Jordan Method

Solution of Linear Algebraic Equations using the Gauss-Jordan Method Solution of Liner Algebric Equtions using the Guss-Jordn Method Populr pproch for solving liner equtions The Guss Jordn method depends on two properties of liner equtions: Scling one or more of ny of the

More information

Stack. A list whose end points are pointed by top and bottom

Stack. A list whose end points are pointed by top and bottom 4. Stck Stck A list whose end points re pointed by top nd bottom Insertion nd deletion tke plce t the top (cf: Wht is the difference between Stck nd Arry?) Bottom is constnt, but top grows nd shrinks!

More information

Languages. L((a (b)(c))*) = { ε,a,bc,aa,abc,bca,... } εw = wε = w. εabba = abbaε = abba. (a (b)(c)) *

Languages. L((a (b)(c))*) = { ε,a,bc,aa,abc,bca,... } εw = wε = w. εabba = abbaε = abba. (a (b)(c)) * Pln for Tody nd Beginning Next week Interpreter nd Compiler Structure, or Softwre Architecture Overview of Progrmming Assignments The MeggyJv compiler we will e uilding. Regulr Expressions Finite Stte

More information

Linear Lists. Linked List Mechanics. Sequential Lists. Linked Lists. 6. LL Mechanics. 6. LL Mechanics. Slides

Linear Lists. Linked List Mechanics. Sequential Lists. Linked Lists. 6. LL Mechanics. 6. LL Mechanics. Slides Lked Lt Mechnics 6. LL Mechnics 1 Ler Lts 6. LL Mechnics 2 Slides 1. Tble Contents 2. Ler Lts 3. Lt Node Design 4. Self Referencg Structures 5. Lt Formtion Exmle 6. Lt Trversl 7. Lked Lt Oertions 8. Dt

More information

6/23/2011. Review: IEEE-754. CSE 2021: Computer Organization. Exercises. Examples. Shakil M. Khan (adapted from Profs. Roumani & Asif)

6/23/2011. Review: IEEE-754. CSE 2021: Computer Organization. Exercises. Examples. Shakil M. Khan (adapted from Profs. Roumani & Asif) 6/23/2 CSE 22: Computer Orgniztion Lecture-8() Floting point computing (IEEE 754) Review: IEEE-754 single: 8 its doule: its single: 23 its doule: 52 its S Exponent Frction S x ( ) ( Frction) 2 (Exponent

More information

L. Yaroslavsky. Fundamentals of Digital Image Processing. Course

L. Yaroslavsky. Fundamentals of Digital Image Processing. Course L. Yroslvsky. Fundmentls of Digitl Imge Processing. Course 0555.330 Lecture. Imge enhncement.. Imge enhncement s n imge processing tsk. Clssifiction of imge enhncement methods Imge enhncement is processing

More information

CIS 1068 Program Design and Abstraction Spring2015 Midterm Exam 1. Name SOLUTION

CIS 1068 Program Design and Abstraction Spring2015 Midterm Exam 1. Name SOLUTION CIS 1068 Progrm Design nd Astrction Spring2015 Midterm Exm 1 Nme SOLUTION Pge Points Score 2 15 3 8 4 18 5 10 6 7 7 7 8 14 9 11 10 10 Totl 100 1 P ge 1. Progrm Trces (41 points, 50 minutes) Answer the

More information

Deterministic. Finite Automata. And Regular Languages. Fall 2018 Costas Busch - RPI 1

Deterministic. Finite Automata. And Regular Languages. Fall 2018 Costas Busch - RPI 1 Deterministic Finite Automt And Regulr Lnguges Fll 2018 Costs Busch - RPI 1 Deterministic Finite Automton (DFA) Input Tpe String Finite Automton Output Accept or Reject Fll 2018 Costs Busch - RPI 2 Trnsition

More information

CSCE 531, Spring 2017, Midterm Exam Answer Key

CSCE 531, Spring 2017, Midterm Exam Answer Key CCE 531, pring 2017, Midterm Exm Answer Key 1. (15 points) Using the method descried in the ook or in clss, convert the following regulr expression into n equivlent (nondeterministic) finite utomton: (

More information

Allocator Basics. Dynamic Memory Allocation in the Heap (malloc and free) Allocator Goals: malloc/free. Internal Fragmentation

Allocator Basics. Dynamic Memory Allocation in the Heap (malloc and free) Allocator Goals: malloc/free. Internal Fragmentation Alloctor Bsics Dynmic Memory Alloction in the Hep (mlloc nd free) Pges too corse-grined for llocting individul objects. Insted: flexible-sized, word-ligned blocks. Allocted block (4 words) Free block (3

More information

Systems I. Logic Design I. Topics Digital logic Logic gates Simple combinational logic circuits

Systems I. Logic Design I. Topics Digital logic Logic gates Simple combinational logic circuits Systems I Logic Design I Topics Digitl logic Logic gtes Simple comintionl logic circuits Simple C sttement.. C = + ; Wht pieces of hrdwre do you think you might need? Storge - for vlues,, C Computtion

More information

Example: 2:1 Multiplexer

Example: 2:1 Multiplexer Exmple: 2:1 Multiplexer Exmple #1 reg ; lwys @( or or s) egin if (s == 1') egin = ; else egin = ; 1 s B. Bs 114 Exmple: 2:1 Multiplexer Exmple #2 Normlly lwys include egin nd sttements even though they

More information

What are suffix trees?

What are suffix trees? Suffix Trees 1 Wht re suffix trees? Allow lgorithm designers to store very lrge mount of informtion out strings while still keeping within liner spce Allow users to serch for new strings in the originl

More information

McAfee Network Security Platform

McAfee Network Security Platform 10/100/1000 Copper Active Fil-Open Bypss Kit Guide Revision E McAfee Network Security Pltform This document descries the contents nd how to instll the McAfee 10/100/1000 Copper Active Fil-Open Bypss Kit

More information

LING/C SC/PSYC 438/538. Lecture 21 Sandiway Fong

LING/C SC/PSYC 438/538. Lecture 21 Sandiway Fong LING/C SC/PSYC 438/538 Lecture 21 Sndiwy Fong Tody's Topics Homework 8 Review Optionl Homework 9 (mke up on Homework 7) Homework 8 Review Question1: write Prolog regulr grmmr for the following lnguge:

More information

Announcements. Scope, Function Calls and Storage Management. Block Structured Languages. Topics. Examples. Simplified Machine Model.

Announcements. Scope, Function Calls and Storage Management. Block Structured Languages. Topics. Examples. Simplified Machine Model. CS 242 2007 Scope, Function Calls and Storage Management John Mitchell Announcements Homework Returned in class Wed; afterwards in 4 th Floor Gates Cabinet SCPD students: attach routing slip, will be returned

More information

Definition of Regular Expression

Definition of Regular Expression Definition of Regulr Expression After the definition of the string nd lnguges, we re redy to descrie regulr expressions, the nottion we shll use to define the clss of lnguges known s regulr sets. Recll

More information

CS 268: IP Multicast Routing

CS 268: IP Multicast Routing Motivtion CS 268: IP Multicst Routing Ion Stoic April 5, 2004 Mny pplictions requires one-to-mny communiction - E.g., video/udio conferencing, news dissemintion, file updtes, etc. Using unicst to replicte

More information

Fall 2018 Midterm 1 October 11, ˆ You may not ask questions about the exam except for language clarifications.

Fall 2018 Midterm 1 October 11, ˆ You may not ask questions about the exam except for language clarifications. 15-112 Fll 2018 Midterm 1 October 11, 2018 Nme: Andrew ID: Recittion Section: ˆ You my not use ny books, notes, extr pper, or electronic devices during this exm. There should be nothing on your desk or

More information