Introduction to Erlang. Franck Petit / Sebastien Tixeuil
|
|
- Claire Cook
- 5 years ago
- Views:
Transcription
1 Introduction to Erlang Franck Petit / Sebastien Tixeuil Firstname.Lastname@lip6.fr
2 Hello World % starts a comment. ends a declaration Every function must be in a module one module per source file source file name is module name +.erl : used for calling functions in other modules
3 Recursive Functions Variables start with upper-case characters ; separates function clauses, separates instructions Variables are local to the function clause Pattern matching and guards to select clauses
4 Recursive Functions -module(mymath). -export([factorial/1]). factorial(0) -> 1; factorial(n) -> N * factorial(n-1). > mymath:factorial(6). 720
5 Tail Recursion The arity is part of the function name Non-exported functions are local to the module
6 Tail Recursion -module(mylists). -export([reverse/1]). reverse(l) -> reverse(l, []). reverse([h T], L) -> reverse(t, [H L]); reverse([], L) -> L. > mylists:reverse([3,2,1]). [1,2,3]
7 Recursion over Lists Pattern-matching selects components of the data _ is a don t care pattern (not a variable) [] is the empty list [X,Y,Z] is a list with exactly three elements [X,Y,Z Tail] has three or more elements
8 List Recursion with Accumulator The same syntax is used to construct lists Strings are simply lists of character codes Avoid adding data to the end of the list
9 Numbers Regular numbers e-05 #-notation for base-n integers 16#ffff $-notation for character codes (ISO ) $A (->65)
10 Atoms Must start with lower case character or be quoted friday unquoted_atoms_cannot_contain_blanks A quoted atom with several blanks hello \n my friend Similar to hashed strings use only one word of data constant-time equality test
11 Tuples Terms separated by, and enclosed in {} {a,12, hello } {1,2,{3, 4},{a,{b,c}}} {} A fixed number of items (similar to structure or record in conventional programming languages) A tuple whose first element is an atom is called a tagged tuple
12 Other Data Types Functions Binaries Process identifiers All terms are ordered and can be compared with <, >, ==, =:=, etc. References No separate booleans Erlang values in general are called terms
13 Built-in Functions Implemented in C All the type tests and conversions are BIFs Most BIFs (not all) are in the module erlang Many common BIFs are auto-imported (recognized without writing erlang:... ) Operators ( +, -, *, /,...) are also really BIFs
14 Standard Libraries Application Libraries Kernel erlang code file inet os Stdlib lists dict sets...
15 Expressions Boolean and/or/xor are strict (always evaluate both arguments) Use andalso/orelse for short circuit evaluation == for equality, not = Always use parentheses when not absolutely certain about the precedence
16 Fun Expressions Anonymous functions (lambda expressions) Can have several clauses All variables in the pattern are new All variable bindings in the fun are local Variables bound in the environment can be used in the fun-body
17 Pattern Matching Match failure causes run-time error Successful matching binds the variables but only if they are not already bound to a value previously bound variables can be used in a pattern a new variable can also be repeated in a pattern
18 Pattern Matching mylength([]) -> 0; mylength([_ T]) -> mylength(t) + 1.
19 Case-switches Any number of clauses Patterns and guards, just as in functions ; separates clauses Use _ as catch-all Variables may also begin with underscore signals I don t intend to use this value
20 If-switches Like a case-switch without the patterns and the when keyword Use true as catch-all factorial(n) when N == 0 -> 1; factorial(n) when N > 0 ->! N * factorial(n - 1).
21 Switching Pattern Matching factorial(0) -> 1; factorial(n) -> N * factorial(n-1). When factorial(n) when N == 0 -> 1; factorial(n) when N > 0 ->! N * factorial(n - 1). If factorial(n) -> if N == 0 -> 1; N > 0 -> N * factorial(n - 1) end. Case factorial(n) -> 1 case (N) of 0 -> 1; N when N > 0 -> N * factorial(n - 1) end.
22 List Processing List Processing BIFs atom_to_list(a) float_to_list(f) integer_to_list(i) tuple_to_list(t) list_to_atom(l)... hd(l) tl(l) length(l) List Processing Functions member(x,l) append(l1,l2) reverse(l) delete_all(x,l)
23 Tuple Processing Tuple Processing BIFs tuple_to_list(t) element(n,t) setelement(n,t,val) size(l)... Multiple Return Values PID, now()...
24 Catching Exceptions throw: user defined error: runtime errors exit: end process only catch throw exceptions normally
25 Processes Code is executed by a process A process keeps track of the program pointer, the stack, the variables values, etc. Every process has a unique process identifier Processes are concurrent
26 Processes: Implementation Virtual machine layer processes Preemptive multitasking Little overhead (e.g processes) Can use multiple CPUs on multiprocessor machines
27 Concurrency Several processes may use the same program code at the same time each has own program counter, stack, and variables programmer need not think about other processes updating the variables
28 Message Passing! is the send operator Pid of the receiver is used as the address Messages are sent asynchronously The sender continues immediately Any value can be sent as a message
29 Echo -module(echo). -export([start/0,loop/0]). start() -> spawn(echo, loop, []). loop() -> receive {From, Message} -> io:format("> echo: ~w Msg: ~w ~n", [self(), Message]), From! Message, loop() end. > Id=echo:start(), Id! {self(),hello}. echo: <0.35.0> Msg: hello {<0.32.0>,hello} >
30 Message Queues Each process has a message queue (mailbox) incoming messages are placed in the queue (no size limit) A process receives a message when it extracts it from the mailbox need not take the first message in the queue
31 Receiving a Message receive-expressions are similar to case switches patterns are used to match messages in the mailbox messages in the queue are tested in order only one message can be extracted each time
32 Selective Receive Patterns and guards permit message selection receive-clauses are tried in order If no message matches, the process suspends and waits for a new message
33 Receive with Timeout A receive-expression can have an after-part can be an integer (milliseconds) or infinity The process waits until a matching message arrives, or the timeout limit is exceeded soft real-time: no guarantees
34 Send and Reply Pids are often included in messages (self()), so that the receiver can reply to the sender If the reply includes the Pid of the second process, it is easier for the first process to recognize the reply
35 Message Order The only guaranteed message order is when both the sender and the receiver are the same for both messages (first-in, firstout)
36 Selecting Unordered Messages Using selective receive, it is possible to choose which messages to accept, even if they arrive in a different order
37 Starting Processes The spawn function creates a new process The new process will run the specified function The spawn operation always returns immediately The return value is the Pid of the child
38 Process Termination A process terminates when: it finishes the function call that it started with there is an exception that is not caught All messages sent to a terminated process will be thrown away Same Pid will not be used before long time
39 A Stateful Server The parameter variables of a server loop can be used to remember the current state
40 Hot Code Swapping When using module:function(...), the latest version of module is always used If the server module is recompiled and reloaded, the process will jump to the new code after handling the next message
41 Registered Processes A process can be registered under a name Any process can send a message to a registered process, or look up the Pid The Pid might change (if the process is restarted and re-registered), but the name stays the same Pid = spawn(?module, server, []), register(myserver, Pid), myserver! Msg.
42 Links and Exit Signals Any two processes can be linked Links are always bidirectionnal When a process dies, an exit signal is sent to all linked processes, which are also killed normal exit does not kill other processes
43 Trapping Exit Signals If a process sets its trap_exit flag, all signals will be caught and turned into normal messages process_flag(trap_exit, true) { EXIT, Pid, ErrorTerm} This way, a process can watch other processes
44 Distribution Running erl with the flag -name xxx starts the Erlang network distribution system makes the virtual machine emulator a node ( xxx@host.domain ) Erlang nodes can communicate over the network (but must find each other first)
45 Connecting Nodes Nodes are connected the first time they try to communicate The function net_adm:ping(node) is the easiest way to set up a connection between nodes returns pong or pang Send a message to a registered process using {Name,Node}! Message
46 Distribution is Transparent Possible to send a Pid from one node to another (Pids are unique across nodes) You can send a message to any process through its Pid (even on another node) You can run several Erlang nodes (with different names) on the same computer
47 Running Remote Processes Variants of the spawn function can start processes directly on another node The module global contains functions for registering and using named processes over the whole network of connected nodes setting global locks
48 Ports: Talking to the Outside Talks to an external (or linked-in) C program A port is connected to the process that opened it The port sends data to the process in messages A process can send data to the port
Introduction to Erlang. Franck Petit / Sebastien Tixeuil
Introduction to Erlang Franck Petit / Sebastien Tixeuil Firstname.Lastname@lip6.fr Erlang History Erlang: Ericsson Language Designed to implement large-scale realtime telecommunication switching systems
More informationAn Introduction to Erlang
An Introduction to Erlang Part 2 - Concurrency Richard Carlsson Processes P1 fib(0) -> 1; fib(1) -> 1; fib(n) when N > 0 -> fib(n-1) + fib(n-2). Whenever an Erlang program is running, the code is executed
More informationErlang: An Overview. Part 2 Concurrency and Distribution. Thanks to Richard Carlsson for most of the slides in this part
Erlang: An Overview Part 2 Concurrency and Distribution Thanks to Richard Carlsson for most of the slides in this part Processes P1 fib(0) -> 1; fib(1) -> 1; fib(n) when N > 0 -> fib(n-1) + fib(n-2). Whenever
More informationAn Introduction to Erlang. Richard Carlsson
An Introduction to Erlang Richard Carlsson Erlang Buzzwords Functional (strict) Single-assignment Dynamically typed Concurrent Distributed Message passing Soft real-time Fault tolerant No sharing Automatic
More informationDISTRIBUTED SYSTEMS [COMP9243] Lecture 1.5: Erlang INTRODUCTION TO ERLANG BASICS: SEQUENTIAL PROGRAMMING 2. Slide 1
DISTRIBUTED SYSTEMS [COMP9243] THE ERLANG ENVIRONMENT Slide 1 Lecture 1.5: Erlang ➀ Introduction ➁ Basics: Sequential programming ➂ Concurrent programming Slide 3 unix% erl 1> 1 + 2. 3 2> c(demo). {ok,demo}
More informationErlang. Functional Concurrent Distributed Soft real-time OTP (fault-tolerance, hot code update ) Open. Check the source code of generic behaviours
Lecture 9 Erlang Erlang Functional Concurrent Distributed Soft real-time OTP (fault-tolerance, hot code update ) Open Check the source code of generic behaviours 2 Functional Haskell call-by-need (lazy)
More informationMessage-passing concurrency in Erlang
Message-passing concurrency in Erlang Lecture 8 of TDA383/DIT390 (Concurrent Programming) Carlo A. Furia Chalmers University of Technology University of Gothenburg SP3 2016/2017 Today s menu Actors and
More informationErlang. Functional Concurrent Distributed Soft real-time OTP (fault-tolerance, hot code update ) Open. Check the source code of generic behaviours
Lecture 10 Erlang Erlang Functional Concurrent Distributed Soft real-time OTP (fault-tolerance, hot code update ) Open Check the source code of generic behaviours 2 Functional Haskell call-by-need (lazy)
More informationErlang: An Overview. Part 1 Sequential Erlang. Thanks to Richard Carlsson for the original version of many slides in this part
Erlang: An Overview Part 1 Sequential Erlang Thanks to Richard Carlsson for the original version of many slides in this part Erlang buzzwords Functional (strict) Single-assignment Dynamically typed Concurrent
More informationPrinciples of Programming Languages (E)
Principles of Programming Languages (E) Matteo Pradella December 1, 2017 Matteo Pradella Principles of Programming Languages (E) December 1, 2017 1 / 49 Erlang: Overview 1 Sequential programming 2 Concurrent
More informationStarting the System & Basic Erlang Exercises
Starting the System & Basic Erlang Exercises These exercises will help you get accustomed with the Erlang development and run time environments. Once you have set up the Erlang mode for emacs, you will
More informationProgramming Paradigms
PP 2016/17 Unit 16 Erlang Modules, Functions and Control Structures 1/31 Programming Paradigms Unit 16 Erlang Modules, Functions and Control Structures J. Gamper Free University of Bozen-Bolzano Faculty
More informationClosures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming
Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Summary 1. Predictive Parsing 2. Large Step Operational Semantics (Natural) 3. Small Step Operational Semantics
More informationAdvanced Functional Programming, 1DL Lecture 2, Cons T Åhs
Advanced Functional Programming, 1DL450 2012 Lecture 2, 2012-11-01 Cons T Åhs Higher order functions hof() -> F = fun(x) -> X * X + 1 end, L = lists:map(f, [1, 2, 3], G = fun([]) -> nil; ([_ _]) -> cons
More informationErlang Concepts. Programming for Beginners, Summer 2011
Programming for Beginners, Summer 2011 Erlang Concepts Erlang is a functional programming language that supports concurrent programming. Computations in Erlang can proceed in parallel on a network of computers,
More informationErlang 101. Google Doc
Erlang 101 Google Doc Erlang? with buzzwords Erlang is a functional concurrency-oriented language with extremely low-weight userspace "processes", share-nothing messagepassing semantics, built-in distribution,
More informationCS390 Principles of Concurrency and Parallelism. Lecture Notes for Lecture #5 2/2/2012. Author: Jared Hall
CS390 Principles of Concurrency and Parallelism Lecture Notes for Lecture #5 2/2/2012 Author: Jared Hall This lecture was the introduction the the programming language: Erlang. It is important to understand
More informationErlangen API Documentation
Erlangen API Documentation Max Rottenkolber Monday, 20 November 2017 Table of Contents 1 erlangen (Package) 1 1.1 *agent-debug* (Variable).................... 1 1.2 *default-mailbox-size* (Variable)...............
More informationErlang: distributed programming
Erlang: distributed May 11, 2012 1 / 21 Fault tolerance in Erlang links, exit signals, system process in Erlang OTP Open Telecom Platform 2 / 21 General idea Links Exit signals System processes Summary
More informationSummer 2017 Discussion 10: July 25, Introduction. 2 Primitives and Define
CS 6A Scheme Summer 207 Discussion 0: July 25, 207 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationProgramming Languages Third Edition. Chapter 9 Control I Expressions and Statements
Programming Languages Third Edition Chapter 9 Control I Expressions and Statements Objectives Understand expressions Understand conditional statements and guards Understand loops and variation on WHILE
More informationClosures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming
Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming t ::= x x. t t t Call-by-value big-step Operational Semantics terms variable v ::= values abstraction x.
More informationMapReduce in Erlang. Tom Van Cutsem
MapReduce in Erlang Tom Van Cutsem 1 Context Masters course on Multicore Programming Focus on concurrent, parallel and... functional programming Didactic implementation of Google s MapReduce algorithm
More informationCOSC441. Lecture 8 Introduction to Erlang
COSC441 Lecture 8 Introduction to Erlang Approach The reference book is Learn You Some Erlang for Great Good! by Fred Hébert. http://learnyousomeerlang.com lets you read it free on-line. What I am going
More informationThe Actor Model. CSCI 5828: Foundations of Software Engineering Lecture 13 10/04/2016
The Actor Model CSCI 5828: Foundations of Software Engineering Lecture 13 10/04/2016 1 Goals Introduce the Actor Model of Concurrency isolation, message passing, message patterns Present examples from
More informationAn Erlang primer. Johan Montelius
An Erlang primer Johan Montelius Introduction This is not a crash course in Erlang since there are plenty of tutorials available on the web. I will however describe the tools that you need so that you
More information3.1 Introduction. Computers perform operations concurrently
PROCESS CONCEPTS 1 3.1 Introduction Computers perform operations concurrently For example, compiling a program, sending a file to a printer, rendering a Web page, playing music and receiving e-mail Processes
More informationErlang. Types, Abstract Form & Core. Salvador Tamarit Muñoz. Universitat Politècnica de València
Erlang Types, Abstract Form & Core Salvador Tamarit Muñoz Universitat Politècnica de València Contents 1 Introduction Motivation 2 Concurrent Erlang 3 Further reading Introduction Introduction Erlang is
More informationWhat s different about Factor?
Harshal Lehri What s different about Factor? Factor is a concatenative programming language - A program can be viewed as a series of functions applied on data Factor is a stack oriented program - Data
More informationA First Look at ML. Chapter Five Modern Programming Languages, 2nd ed. 1
A First Look at ML Chapter Five Modern Programming Languages, 2nd ed. 1 ML Meta Language One of the more popular functional languages (which, admittedly, isn t saying much) Edinburgh, 1974, Robin Milner
More informationMain Memory (Part I)
Main Memory (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir H. Payberah (Tehran Polytechnic) Main Memory 1393/8/5 1 / 47 Motivation and Background Amir
More informationProcesses and Non-Preemptive Scheduling. Otto J. Anshus
Processes and Non-Preemptive Scheduling Otto J. Anshus Threads Processes Processes Kernel An aside on concurrency Timing and sequence of events are key concurrency issues We will study classical OS concurrency
More informationParallel Programming in Erlang (PFP Lecture 10) John Hughes
Parallel Programming in Erlang (PFP Lecture 10) John Hughes What is Erlang? Haskell Erlang - Types - Lazyness - Purity + Concurrency + Syntax If you know Haskell, Erlang is easy to learn! QuickSort again
More informationDebugger Copyright Ericsson AB. All Rights Reserved. Debugger September 24, 2018
Debugger Copyright 1997-2018 Ericsson AB. All Rights Reserved. Debugger 4.2.6 September 24, 2018 Copyright 1997-2018 Ericsson AB. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the
More informationThe PCAT Programming Language Reference Manual
The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language
More informationConcurrent & Distributed Systems Supervision Exercises
Concurrent & Distributed Systems Supervision Exercises Stephen Kell Stephen.Kell@cl.cam.ac.uk November 9, 2009 These exercises are intended to cover all the main points of understanding in the lecture
More informationThe Actor Model, Part Two. CSCI 5828: Foundations of Software Engineering Lecture 18 10/23/2014
The Actor Model, Part Two CSCI 5828: Foundations of Software Engineering Lecture 18 10/23/2014 1 Goals Cover the material presented in Chapter 5, of our concurrency textbook In particular, the material
More informationCPL 2016, week 10. Clojure functional core. Oleg Batrashev. April 11, Institute of Computer Science, Tartu, Estonia
CPL 2016, week 10 Clojure functional core Oleg Batrashev Institute of Computer Science, Tartu, Estonia April 11, 2016 Overview Today Clojure language core Next weeks Immutable data structures Clojure simple
More informationThe SPL Programming Language Reference Manual
The SPL Programming Language Reference Manual Leonidas Fegaras University of Texas at Arlington Arlington, TX 76019 fegaras@cse.uta.edu February 27, 2018 1 Introduction The SPL language is a Small Programming
More informationLecture 9. Part I. Overview of Message Passing. Communication Coupling. Decoupling Blackboard. Decoupling Broadcast. Linda and Erlang.
Lecture 9 Part I Linda and Erlang Linda Overview of Message Passing Communication Coupling One process sends a message Another process awaits for a message We will consider two dimensions of this approach:
More informationCh 9: Control flow. Sequencers. Jumps. Jumps
Ch 9: Control flow Sequencers We will study a number of alternatives traditional sequencers: sequential conditional iterative jumps, low-level sequencers to transfer control escapes, sequencers to transfer
More informationPrecept 2: Non-preemptive Scheduler. COS 318: Fall 2018
Precept 2: Non-preemptive Scheduler COS 318: Fall 2018 Project 2 Schedule Precept: Monday 10/01, 7:30pm (You are here) Design Review: Monday 10/08, 3-7pm Due: Sunday 10/14, 11:55pm Project 2 Overview Goal:
More informationPython in 10 (50) minutes
Python in 10 (50) minutes https://www.stavros.io/tutorials/python/ Python for Microcontrollers Getting started with MicroPython Donald Norris, McGrawHill (2017) Python is strongly typed (i.e. types are
More informationCSE 451 Midterm 1. Name:
CSE 451 Midterm 1 Name: 1. [2 points] Imagine that a new CPU were built that contained multiple, complete sets of registers each set contains a PC plus all the other registers available to user programs.
More informationSMD149 - Operating Systems
SMD149 - Operating Systems Roland Parviainen November 3, 2005 1 / 45 Outline Overview 2 / 45 Process (tasks) are necessary for concurrency Instance of a program in execution Next invocation of the program
More informationOperating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski
Operating Systems Design Fall 2010 Exam 1 Review Paul Krzyzanowski pxk@cs.rutgers.edu 1 Question 1 To a programmer, a system call looks just like a function call. Explain the difference in the underlying
More informationERLANG BITS AND PIECES
ERLANG BITS AND PIECES Curt Clifton Rose-Hulman Institute of Technology Update ErlangInClass, open bap.erl GUARDS Guards are boolean-valued Erlang expressions, used in Function definitions: max(x,y) when
More informationLecture 5: Declarative Programming. The Declarative Kernel Language Machine. September 12th, 2011
Lecture 5: Declarative Programming. The Declarative Kernel Language Machine September 12th, 2011 1 Lecture Outline Declarative Programming contd Dataflow Variables contd Expressions and Statements Functions
More informationAll you need is fun. Cons T Åhs Keeper of The Code
All you need is fun Cons T Åhs Keeper of The Code cons@klarna.com Cons T Åhs Keeper of The Code at klarna Architecture - The Big Picture Development - getting ideas to work Code Quality - care about the
More informationOn Academic Dishonesty. Declarative Computation Model. Single assignment store. Single assignment store (2) Single assignment store (3)
Declarative Computation Model Single assignment store (VRH 2.2) Kernel language syntax (VRH 2.3) Carlos Varela RPI October 6, 2009 Adapted with permission from: Seif Haridi KTH Peter Van Roy UCL On Academic
More informationTasks. Task Implementation and management
Tasks Task Implementation and management Tasks Vocab Absolute time - real world time Relative time - time referenced to some event Interval - any slice of time characterized by start & end times Duration
More informationProgramming Language Concepts, cs2104 Lecture 04 ( )
Programming Language Concepts, cs2104 Lecture 04 (2003-08-29) Seif Haridi Department of Computer Science, NUS haridi@comp.nus.edu.sg 2003-09-05 S. Haridi, CS2104, L04 (slides: C. Schulte, S. Haridi) 1
More informationScheme as implemented by Racket
Scheme as implemented by Racket (Simple view:) Racket is a version of Scheme. (Full view:) Racket is a platform for implementing and using many languages, and Scheme is one of those that come out of the
More informationPace 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 informationChapter 3: Processes. Operating System Concepts 8 th Edition,
Chapter 3: Processes, Silberschatz, Galvin and Gagne 2009 Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication 3.2 Silberschatz, Galvin and Gagne 2009
More informationRoadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - III Processes. Louisiana State University. Processes. September 1 st, 2009
CSC 4103 - Operating Systems Fall 2009 Lecture - III Processes Tevfik Ko!ar Louisiana State University September 1 st, 2009 1 Roadmap Processes Basic Concepts Process Creation Process Termination Context
More informationScheme: 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 informationDefining Functions. CSc 372. Comparative Programming Languages. 5 : Haskell Function Definitions. Department of Computer Science University of Arizona
Defining Functions CSc 372 Comparative Programming Languages 5 : Haskell Function Definitions Department of Computer Science University of Arizona collberg@gmail.com When programming in a functional language
More informationLecture 8. Linda and Erlang
Lecture 8 Linda and Erlang Part I Linda 2 Overview of Message Passing One process sends a message Another process awaits for a message We will consider two dimensions of this approach: What form of synchronisation
More informationCS350: Final Exam Review
University of Waterloo CS350: Final Exam Review Gwynneth Leece, Andrew Song, Rebecca Putinski Winter, 2010 Intro, Threads & Concurrency What are the three views of an operating system? Describe them. Define
More informationOperating Systems. Figure: Process States. 1 P a g e
1. THE PROCESS CONCEPT A. The Process: A process is a program in execution. A process is more than the program code, which is sometimes known as the text section. It also includes the current activity,
More informationSCHEME 8. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. March 23, 2017
SCHEME 8 COMPUTER SCIENCE 61A March 2, 2017 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationProcesses, PCB, Context Switch
THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering EIE 272 CAOS Operating Systems Part II Processes, PCB, Context Switch Instructor Dr. M. Sakalli enmsaka@eie.polyu.edu.hk
More informationToday s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads
Today s Topics COS 318: Operating Systems Implementing Threads u Thread implementation l Non-preemptive versus preemptive threads l Kernel vs. user threads Jaswinder Pal Singh and a Fabulous Course Staff
More informationProcesses. Dr. Yingwu Zhu
Processes Dr. Yingwu Zhu Process Growing Memory Stack expands automatically Data area (heap) can grow via a system call that requests more memory - malloc() in c/c++ Entering the kernel (mode) Hardware
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationChapter 6 Control Flow. June 9, 2015
Chapter 6 Control Flow June 9, 2015 Expression evaluation It s common in programming languages to use the idea of an expression, which might be a simple object function invocation over some number of arguments
More informationCS Introduction to Data Structures How to Parse Arithmetic Expressions
CS3901 - Introduction to Data Structures How to Parse Arithmetic Expressions Lt Col Joel Young One of the common task required in implementing programming languages, calculators, simulation systems, and
More informationCS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)
CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) Introduction This semester, through a project split into 3 phases, we are going
More informationCS 221 Review. Mason Vail
CS 221 Review Mason Vail Inheritance (1) Every class - except the Object class - directly inherits from one parent class. Object is the only class with no parent. If a class does not declare a parent using
More informationHaskell: Lists. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Friday, February 24, Glenn G.
Haskell: Lists CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Friday, February 24, 2017 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks
More information9/21/17. Outline. Expression Evaluation and Control Flow. Arithmetic Expressions. Operators. Operators. Notation & Placement
Outline Expression Evaluation and Control Flow In Text: Chapter 6 Notation Operator evaluation order Operand evaluation order Overloaded operators Type conversions Short-circuit evaluation of conditions
More informationREVIEW OF COMMONLY USED DATA STRUCTURES IN OS
REVIEW OF COMMONLY USED DATA STRUCTURES IN OS NEEDS FOR EFFICIENT DATA STRUCTURE Storage complexity & Computation complexity matter Consider the problem of scheduling tasks according to their priority
More informationC311 Lab #3 Representation Independence: Representation Independent Interpreters
C311 Lab #3 Representation Independence: Representation Independent Interpreters Will Byrd webyrd@indiana.edu February 5, 2005 (based on Professor Friedman s lecture on January 29, 2004) 1 Introduction
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationDRAWING ENVIRONMENT DIAGRAMS
DRAWING ENVIRONMENT DIAGRAMS COMPUTER SCIENCE 61A September 10, 2012 0.1 Background A frame is a location where variable bindings are stored A binding is a connection between a name and a value. The name
More informationAnnouncements. Lab Friday, 1-2:30 and 3-4:30 in Boot your laptop and start Forte, if you brought your laptop
Announcements Lab Friday, 1-2:30 and 3-4:30 in 26-152 Boot your laptop and start Forte, if you brought your laptop Create an empty file called Lecture4 and create an empty main() method in a class: 1.00
More informationsample exam Concurrent Programming tda383/dit390 Sample exam March 2016 Time:?? Place: Johanneberg
sample exam Concurrent Programming tda383/dit390 Sample exam March 2016 Time:?? Place: Johanneberg Responsible Michał Pałka 0707966066 Result Available no later than?-?-2016 Aids Max 2 books and max 4
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationDebugger Application (DEBUGGER) version 3.1
Debugger Application (DEBUGGER) version 3.1 Typeset in L A TEX from SGML source using the DocBuilder-0.9.7 Document System. Contents 1 Debugger User s Guide 1 1.1 Debugger...........................................
More informationLecture 8: Recursion and Iteration. Exceptions. Declarative Programming.
Lecture 8: Recursion and Iteration. Exceptions. Declarative Programming. September 26th, 2010 Lecture 8: Recursion and Iteration. Exceptions. Declarative Programming. (1/48) Lecture Outline Memory Management,
More informationCSc 520 Principles of Programming Languages. 26 : Control Structures Introduction
CSc 520 Principles of Programming Languages 26 : Control Structures Introduction Christian Collberg Department of Computer Science University of Arizona collberg+520@gmail.com Copyright c 2008 Christian
More informationErlang functional programming in a concurrent world
KTH ROYAL INSTITUTE OF TECHNOLOGY Erlang functional programming in a concurrent world Johan Montelius and Vladimir Vlassov Erlang Concurrent Oriented Programming processes have state communicate using
More informationErlang functional programming in a concurrent world Johan Montelius and Vladimir Vlassov
KTH ROYAL INSTITUTE OF TECHNOLOGY Erlang functional programming in a concurrent world Johan Montelius and Vladimir Vlassov Erlang Concurrent Oriented Programming processes have state communicate using
More informationScenes From the Language Struggle in Toronto, Ontario. Mike Nolta
Scenes From the Language Struggle in Toronto, Ontario Mike Nolta Ch-Ch-Changes OpenMP & MPI are fine for now, but we need language support for parallelism. Corbato s Law: The number of lines of code a
More informationCompiler Application (COMPILER) version 4.4
Compiler Application (COMPILER) version 4.4 Typeset in L A TEX from SGML source using the DocBuilder-0.9 Document System. Contents 1 Compiler Reference Manual 1 1.1 compile...........................................
More informationCS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017
CS 471 Operating Systems Yue Cheng George Mason University Fall 2017 Outline o Process concept o Process creation o Process states and scheduling o Preemption and context switch o Inter-process communication
More informationProgramming for the Web with PHP
Aptech Ltd Version 1.0 Page 1 of 11 Table of Contents Aptech Ltd Version 1.0 Page 2 of 11 Abstraction Anonymous Class Apache Arithmetic Operators Array Array Identifier arsort Function Assignment Operators
More informationProcesses and More. CSCI 315 Operating Systems Design Department of Computer Science
Processes and More CSCI 315 Operating Systems Design Department of Computer Science Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating Systems Concepts,
More informationCliff Moon. Bottleneck Whack-A-Mole. Thursday, March 21, 13
Cliff Moon Bottleneck Whack-A-Mole Whack-A-Mole Production Experience Your Mileage May Vary. This is all folklore. Unless otherwise specified - R14B04. Down in the weeds. Collectors Terminates SSL and
More informationPart V. Process Management. Sadeghi, Cubaleska RUB Course Operating System Security Memory Management and Protection
Part V Process Management Sadeghi, Cubaleska RUB 2008-09 Course Operating System Security Memory Management and Protection Roadmap of Chapter 5 Notion of Process and Thread Data Structures Used to Manage
More informationChapters 9 & 10: Memory Management and Virtual Memory
Chapters 9 & 10: Memory Management and Virtual Memory Important concepts (for final, projects, papers) addressing: physical/absolute, logical/relative/virtual overlays swapping and paging memory protection
More informationA Small Web Server. Programming II - Elixir Version. Johan Montelius. Spring Term 2018
A Small Web Server Programming II - Elixir Version Johan Montelius Spring Term 2018 Introduction Your task is to implement a small web server in Elixir. exercise is that you should be able to: The aim
More informationProcesses COMPSCI 386
Processes COMPSCI 386 Elements of a Process A process is a program in execution. Distinct processes may be created from the same program, but they are separate execution sequences. call stack heap STACK
More informationCourse: Operating Systems Instructor: M Umair. M Umair
Course: Operating Systems Instructor: M Umair Process The Process A process is a program in execution. A program is a passive entity, such as a file containing a list of instructions stored on disk (often
More informationOperating Systems Comprehensive Exam. Spring Student ID # 3/16/2006
Operating Systems Comprehensive Exam Spring 2006 Student ID # 3/16/2006 You must complete all of part I (60%) You must complete two of the three sections in part II (20% each) In Part I, circle or select
More informationSCHEME 7. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. October 29, 2015
SCHEME 7 COMPUTER SCIENCE 61A October 29, 2015 1 Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationChapter 8 & Chapter 9 Main Memory & Virtual Memory
Chapter 8 & Chapter 9 Main Memory & Virtual Memory 1. Various ways of organizing memory hardware. 2. Memory-management techniques: 1. Paging 2. Segmentation. Introduction Memory consists of a large array
More informationComputer architecture. A simplified model
Computer architecture A simplified model Computers architecture One (or several) CPU(s) Main memory A set of devices (peripherals) Interrupts Direct memory access Computers architecture Memory Keyboard
More informationPrinciples of Programming Languages 2017W, Functional Programming
Principles of Programming Languages 2017W, Functional Programming Assignment 3: Lisp Machine (16 points) Lisp is a language based on the lambda calculus with strict execution semantics and dynamic typing.
More information