Dining Philosophers with π-calculus
|
|
- Earl Hill
- 6 years ago
- Views:
Transcription
1 Dining Philosophers with π-calculus Matthew Johnson January 28, 2015 Overview The primary goal of this project was to explore the π-calculus by implementing a deadlockfree solution to the dining philosophers problem. Some π-calculus resources I found useful and can provide more information if you are interested are the CSinParallel Module, the Wikipedia page, and this π-calculus FAQ. For the dining philosophers, I used Allen Downey s Little Book of Semaphores in addition to the class materials. The π-calculus Two of the most common models of computation are Turing machines, which focus on sequential execution of instructions and modification of memory addresses and underlie imperative languages like C and Python, and λ-calculus, which creates and composes functions to perform calculations and is the theoretical basis of functional languages like Lisp, Erlang, and Haskell. These models, while useful for many applications, have a major shortcoming in that they are sequential and don t directly address some of the theory behind parallel computing. The π-calculus (and other process calculi) fill this gap by focusing on passing messages between concurrent processes to perform computations. Although the word calculus often refers to the math of differentiation and integration, it can more generally refer to any sort of strategy for performing calculations through symbolic 1
2 manipulation. Before trying to apply π-calculus to try to solve any problem, it is important first to understand some of the basic symbols and manipulations that it allows. Symbols and Components One of the key ideas of π-calculus is a name. A name functions both as a channel which can be used to send messages and also as a variable that is sent through a channel. In general, names are in lower case. In all of the below, P and Q represent generic processes. Symbol Name General Meaning/Interpretation 0 nil process a process that has stopped or does nothing P Q concurrency the processes P and Q executing in parallel c(x).p input prefixing wait for a message on channel c, store the message as name x, and then continue with process P c x.p output prefixing send the name x across channel c, then continue with process P (νc)p name allocation creates a new channel name in the process P!P replication create copies of P, as in a server forking to process a user s request or a new thread being spawned to execute a function Axioms Given these symbols, we also need rules to manipulate them. There are two categories of axioms: structural congruence and reduction semantics 2
3 Structural Congruence Name Alpha-conversion Parallel Composition Restriction Relation between Restriction and Parallelism Replication Congruence P Q if renaming bound variables (i.e., names created through name allocation or output prefixing) can transform P into Q (P and Q are the same if only the names they use are different.) P Q Q P (P Q) R P (Q R) P 0 P (Concurrent processes can be written in any order with any grouping; the concurrency operator is commutative, associative, and has identity.) (νx)(νy)p (νy)(νx)p (νx)0 0 (The order in which names are created doesn t matter, and the nil process doesn t uses any names.) (νx)(p Q) (νx)p Q if x is not a free name of Q ( Scope extension axiom ; if a process doesn t use a name, it doesn t need to be in the scope of the name, but can be.)!p P!P (A replicating process can create any number of copies.) Reduction Semantics Name Communication Reduction x z.p x(y).q P Q[z/y] (Sending a name replaces all instances of y in Q with z.) if P Q then P R Q R (If you can reduce P to Q, then you can also do this is parallel with R.) if P Q then (νx)p (νx)q (If you can reduce P to Q, then you can also do this with the extra name x.) if P P and P Q where Q Q, then P Q (Congruent processes reduce to congruent processes.) 3
4 Examples To help illustrate these, we will consider a sample client-server application from the π-calculus FAQ linked from above. In this example, we use an extension of π-calculus which allows sending and receiving multiple names at a time and also includes arithmetic. The operation that the server will perform is an increment: it will receive a message containing a channel and a number, and it will send a message on the channel it received containing the number it received, plus 1. One instance of this operation looks something like this: incr(c, x).c x In order to change this into a server, we need to make it possible for this process to be carried out on demand. We can accomplish this by simply adding the replication operator,! :!incr(c, x).c x Now whenever some process sends a message on the channel incr, this process can spawn a new copy of the increment service, which will handle the message. In order to use this service, we send a message containing a channel and a number on the channel incr, and then listen for a response on the channel that we sent. Typically, in such cases we create a new name to send to ensure that the channel is exclusive to this client process and the process spawned by the server that is handling the request. Given this, a client process might look like this: (νa)incr a, 17.a(y).P To see how the axioms help understand the execution, we will informally trace the execution of a client-server transaction (a more explicit walk-through appears near the end of the CSinParallel page). We start with the client and server running in parallel: (νa)incr a, 17.a(y).P!incr(c, x).c x The replication operator allows the server to spawn a new copy of the increment service: (νa)incr a, 17.a(y).P incr(c, x).c x + 1.0!incr(c, x).c x Since we have input and output on the same channel, we can apply the communication 4
5 reduction: (νa)a(y).p c x + 1.0[a, 17/c, x]!incr(c, x).c x We can further simply this by substituting the sent values wherever they appear: (νa)a(y).p a !incr(c, x).c x Once more, we can use the communication reduction: (νa)p [18/y] 0!incr(c, x).c x If a doesn t appear anywhere in the process P, we can simply drop the creation of the name a by one of the restriction congruence axioms. Additionally, the parallel composition axioms let us drop the process 0. This gives the last step of this computation: P [18/y]!incr(c, x).c x which is what we were expecting: the client proceeds with an incremented number, and the server is still available to handle more requests. Although the basic π-calculus is Turing complete (informally, anything that can be computed using a language like C can also be computed using π-calculus), as this example shows, you can work much more easily if you explicitly include extensions such as arithmetic and the ability to send/receive multiple names at once. Other common extensions include general conveniences such as control structures, more data types, or new operators, and specific applications, such as cryptography, add their own primitives for easier modelling. For the implementation of the dining philosophers, however, we will only need the basic π-calculus described above. Dining Philosophers Strategy The solution that we will implement comes from The Little Book of Semaphores by Allen B. Downey and is a variation of the waiter solution we saw in class. Both the waiter solution and this solution try to prevent deadlock by avoiding the case that each of the 5 philosophers is holding a chopstick. Whereas the waiter solution enforces this 5
6 by keeping track of which chopsticks are in use and whether giving out the last chopstick would cause a deadlock, Downey s solution enforces this by ensuring that at most 4 of the 5 philosophers are holding a chopstick at a time. This way, even if all 5 chopsticks are in use, we are guaranteed that at least one of the philosophers has two chopsticks, and deadlock is avoided. We can imagine this solution by picturing not a waiter, but a bouncer: while the philosophers are thinking, they are outside the dining room. Before they can start picking up chopsticks, they must first enter the dining room, but the bouncer ensures that at most 4 of the philosophers are in the dining room at a time. This solution is especially nice for π-calculus since it requires less bookkeeping, which is convenient since π-calculus doesn t readily offer the structures needed by the waiter solution. Semaphores As you might guess, a solution from The Little Book of Semaphores requires semaphores. A semaphore is a useful tool for synchronisation: the basic idea is that the semaphore has an internal counter and two operations, often called wait and signal, for interacting with this counter. In the context of this problem, the counter represents the number of some resource that are available, wait claims a resource if it is available and otherwise blocks until one is available, and signal gives a claimed resourced to a blocked process, if there is one, and simply returns it otherwise. We can use semaphores both to control how many philosophers are allowed in the dining room and to ensure that at most one philosopher is holding a chopstick at a time. For the dining room semaphore, we initialize the semaphore to 4 (to indicate that up to 4 philosophers can be in the room at a time), waiting on the semaphore corresponds to trying to enter the room, and signalling the semaphore corresponds to leaving the room. For a chopstick semaphore, we initialize the semaphore to 1 (since only one philosopher can hold a chopstick at a time), wait corresponds to trying to pick up the chopstick, and signal corresponds to putting the chopstick back on the table. 6
7 Fortunately, it is fairly simple to implement wait and signal using the notation of π-calculus:!wait(c).sem(x).c x.0!signal(c).sem c.0 and we initialize this semaphore to n by having n copies of the process sem 0.0 (the value 0 sent is arbitrary.) In order to use this semaphore, a process will do something like (νa)wait a.a(x). CRIT.signal a.0 where CRIT is the critical section. In this implementation, the number of unresolved sem x.0 processes can be interpreted as the number of resources available. If there are one or more unresolved sem x.0 processes, the sem(x) operation in the wait process can immediately receive a message, and it will let the process that is trying to wait on the semaphore continue. If there are no unresolved sem x.0 processes, the sem(x) operation will block until one appears. Conversely, signal creates a sem x.0 process, which will either immediately communicate with a sem(x), unblocking it, or remain unresolved until some process tries to wait. Loops Before we can implement dining philosophers, we need one more structure to help represent the philosophers. In the dining philosophers, each of the 5 philosophers is in an infinite loop alternating between thinking and eating. Although the π-calculus provides the replication operator, this on its own isn t enough if the body of one of the philosopher processes is represented by the process PHIL, the process! PHIL would create infinitely many clones of this philosopher, which would be problematic. In order to ensure that exactly one copy of each philosopher is active at a time, we can combine replication with communication so that as one copy of a philosopher ends, it starts 7
8 another copy. This idea can be implemented in this way:!loop(x). PHIL.loop x.0 On its own, however, this doesn t do anything since the first operation of each copy is a receieve, every copy is blocked until there is some send. To resolve this, we can kick-start this philosopher with the process loop x.0. (It is worth noting, that, although we don t use x for anything is dining philosophers, this pattern could be used to pass information between iterations.) Putting Things Together The only thing remaining, then, is the body of the philosophers themselves. In each thinkeat cycle, the philosopher must think (which I will represent with THINK), wait to enter the dining room, obtain both chopsticks, eat (EAT), return the chopsticks, and leave the room. We can represent one iteration of this cycle as the process (νphil). wait room phil.phil(x).wait L chop phil.phil(x).wait R chop phil.phil(x). EAT. signal R chop phil.signal L chop phil.signal room phil. 0 where wait room, signal room, wait L chop, signal L chop, wait R chop, and signal R chop are the signal and wait channels for the semaphores representing the space in the room and left and right chopsticks. Adding the loop construct from above to the philosopher process, we obtain this process as 8
9 a complete philosopher: (νphil) (!phil loop(x). wait room phil.phil(x).wait L chop phil.phil(x).wait R chop phil.phil(x). EAT. signal R chop phil.signal L chop phil.signal room phil. phil loop x. 0 phil loop x.0) Thus, we can represent the entire five-philosopher problem with a process containing the parallel execution of five of these philosopher processes (the names changed so they are distinguishable and use the correct chopsticks), one semaphore initialized to 1 for each of the chopsticks, and one semaphore initialized to 4 for the room. Complete Listing This is the complete π-calculus version of my implementation of the dining philosophers solution.!wait room(c).sem r(x).c x.0!signal room(c).sem r c.0 sem r 0.0 sem r 0.0 sem r 0.0 sem r 0.0!wait chop0(c).sem c0(x).c x.0!signal chop0(c).sem c0) c.0 sem c0 0.0!wait chop1(c).sem c1(x).c x.0!signal chop1(c).sem c1 c.0 sem c1 0.0!wait chop2(c).sem c2(x).c x.0!signal chop2(c).sem c2 c.0 sem c2 0.0!wait chop3(c).sem c3(x).c x.0!signal chop3(c).sem c3 c.0 sem c
10 !wait chop4(c).sem c4(x).c x.0!signal chop4(c).sem c4 c.0 sem c4 0.0 (νphil0)!loop phil0(x). wait room phil0.phil0(x).wait chop0 phil0.phil0(x).wait chop1 phil0.phil0(x). EAT. signal chop1 phil0.signal chop0 phil0.signal room phil0. loop phil0 x.0 loop phil0 x.0 (νphil1)!loop phil1(x). wait room phil1.phil1(x).wait chop1 phil1.phil1(x).wait chop2 phil1.phil1(x). EAT. signal chop2 phil1.signal chop1 phil1.signal room phil1. loop phil1 x.0 loop phil1 x.0 (νphil2)!loop phil2(x). wait room phil2.phil2(x).wait chop2 phil2.phil2(x).wait chop3 phil2.phil2(x). EAT. signal chop3 phil2.signal chop2 phil2.signal room phil2. loop phil2 x.0 loop phil2 x.0 (νphil3)!loop phil3(x). wait room phil3.phil3(x).wait chop3 phil3.phil3(x).wait chop4 phil3.phil3(x). EAT. signal chop4 phil3.signal chop3 phil3.signal room phil3. loop phil3 x.0 loop phil3 x.0 10
11 (νphil4)!loop phil4(x). wait room phil4.phil4(x).wait chop4 phil4.phil4(x).wait chop0 phil4.phil4(x). EAT. signal chop0 phil4.signal chop4 phil4.signal room phil4. loop phil4 x.0 loop phil4 x.0 11
A Theory of Parallel Computation The π-calculus
A Theory of Parallel Computation The π-calculus Background DFAs, NFAs, pushdown automata, Turing machines... All are mathematical entities that model computation. These abstract systems have concrete,
More informationDealing with Issues for Interprocess Communication
Dealing with Issues for Interprocess Communication Ref Section 2.3 Tanenbaum 7.1 Overview Processes frequently need to communicate with other processes. In a shell pipe the o/p of one process is passed
More information6.001 Notes: Section 15.1
6.001 Notes: Section 15.1 Slide 15.1.1 Our goal over the next few lectures is to build an interpreter, which in a very basic sense is the ultimate in programming, since doing so will allow us to define
More informationIntroduction 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 informationThreading the Code. Self-Review Questions. Self-review 11.1 What is a thread and what is a process? What is the difference between the two?
Threading the Code 11 Self-Review Questions Self-review 11.1 What is a thread and what is a process? What is the difference between the two? Self-review 11.2 What does the scheduler in an operating system
More informationFrom the λ-calculus to Functional Programming Drew McDermott Posted
From the λ-calculus to Functional Programming Drew McDermott drew.mcdermott@yale.edu 2015-09-28 Posted 2015-10-24 The λ-calculus was intended from its inception as a model of computation. It was used by
More informationDeadlock and Monitors. CS439: Principles of Computer Systems September 24, 2018
Deadlock and Monitors CS439: Principles of Computer Systems September 24, 2018 Bringing It All Together Processes Abstraction for protection Define address space Threads Share (and communicate) through
More informationProcess Synchronization. studykorner.org
Process Synchronization Semaphore Implementation Must guarantee that no two processes can execute wait () and signal () on the same semaphore at the same time The main disadvantage of the semaphore definition
More informationProcess 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 informationStop coding Pascal. Saturday, April 6, 13
Stop coding Pascal...emotional sketch about past, present and future of programming languages, Python, compilers, developers, Life, Universe and Everything Alexey Kachayev CTO at KitApps Inc. Open source
More informationProgramming with Math and Logic
.. Programming with Math and Logic an invitation to functional programming Ed Morehouse Wesleyan University The Plan why fp? terms types interfaces The What and Why of Functional Programming Computing
More information3.7 Denotational Semantics
3.7 Denotational Semantics Denotational semantics, also known as fixed-point semantics, associates to each programming language construct a well-defined and rigorously understood mathematical object. These
More informationDining Philosophers, Semaphores
CS 220: Introduction to Parallel Computing Dining Philosophers, Semaphores Lecture 27 Today s Schedule Dining Philosophers Semaphores Barriers Thread Safety 4/30/18 CS 220: Parallel Computing 2 Today s
More informationSemaphores. 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 informationCOMP80 Lambda Calculus Programming Languages Slides Courtesy of Prof. Sam Guyer Tufts University Computer Science History Big ideas Examples:
COMP80 Programming Languages Slides Courtesy of Prof. Sam Guyer Lambda Calculus Formal system with three parts Notation for functions Proof system for equations Calculation rules called reduction Idea:
More informationInterprocess 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 informationDeadlock and Monitors. CS439: Principles of Computer Systems February 7, 2018
Deadlock and Monitors CS439: Principles of Computer Systems February 7, 2018 Last Time Terminology Safety and liveness Atomic Instructions, Synchronization, Mutual Exclusion, Critical Sections Synchronization
More informationConcurrency. Glossary
Glossary atomic Executing as a single unit or block of computation. An atomic section of code is said to have transactional semantics. No intermediate state for the code unit is visible outside of the
More informationCS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019
CS 31: Introduction to Computer Systems 22-23: Threads & Synchronization April 16-18, 2019 Making Programs Run Faster We all like how fast computers are In the old days (1980 s - 2005): Algorithm too slow?
More informationOperating 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 informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Lambda Calculus CMSC 330 1 Programming Language Features Many features exist simply for convenience Multi-argument functions foo ( a, b, c ) Use currying
More informationCOMP3151/9151 Foundations of Concurrency Lecture 8
1 COMP3151/9151 Foundations of Concurrency Lecture 8 Liam O Connor CSE, UNSW (and data61) 8 Sept 2017 2 Shared Data Consider the Readers and Writers problem from Lecture 6: Problem We have a large data
More information(Refer Slide Time: 1:36)
Principles of Programming Languages Dr. S. Arun Kumar Department of Computer Science & Engineering Indian Institute of Technology, Delhi Lecture - 39 Parameters Welcome to lecture 39. So today we will
More informationChapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6.
Part Three - Process Coordination Chapter 6: Synchronization 6.1 Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure
More informationChapter 6: Process Synchronization
Chapter 6: Process Synchronization Chapter 6: Synchronization 6.1 Background 6.2 The Critical-Section Problem 6.3 Peterson s Solution 6.4 Synchronization Hardware 6.5 Mutex Locks 6.6 Semaphores 6.7 Classic
More informationDatabase Management System Prof. D. Janakiram Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.
Database Management System Prof. D. Janakiram Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. # 20 Concurrency Control Part -1 Foundations for concurrency
More informationHomework #3. CS 318/418/618, Fall Handout: 10/09/2017
CS 318/418/618, Fall 2017 Homework #3 Handout: 10/09/2017 1. Microsoft.NET provides a synchronization primitive called a CountdownEvent. Programs use CountdownEvent to synchronize on the completion of
More informationParallelism and Concurrency. Motivation, Challenges, Impact on Software Development CSE 110 Winter 2016
Parallelism and Concurrency Motivation, Challenges, Impact on Software Development CSE 110 Winter 2016 About These Slides Due to the nature of this material, this lecture was delivered via the chalkboard.
More informationType Systems Winter Semester 2006
Type Systems Winter Semester 2006 Week 4 November 8 November 15, 2006 - version 1.1 The Lambda Calculus The lambda-calculus If our previous language of arithmetic expressions was the simplest nontrivial
More informationBST Deletion. First, we need to find the value which is easy because we can just use the method we developed for BST_Search.
BST Deletion Deleting a value from a Binary Search Tree is a bit more complicated than inserting a value, but we will deal with the steps one at a time. First, we need to find the value which is easy because
More informationSynchronization. Silvina Hanono Wachman Computer Science & Artificial Intelligence Lab M.I.T.
Synchronization Silvina Hanono Wachman Computer Science & Artificial Intelligence Lab M.I.T. L24-1 Reminders All labs must be completed by this Friday, Dec. 7 th to pass the course Any work you intend
More informationCSc 372. Comparative Programming Languages. 2 : Functional Programming. Department of Computer Science University of Arizona
1/37 CSc 372 Comparative Programming Languages 2 : Functional Programming Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2013 Christian Collberg 2/37 Programming Paradigms
More informationClass Notes, 3/21/07, Operating Systems
Class Notes, 3/21/07, Operating Systems Hi, Jane. Thanks again for covering the class. One of the main techniques the students need to how to recognize when there is a cycle in a directed graph. (Not all
More information6.001 Notes: Section 8.1
6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything
More informationLiveness properties. Deadlock
Liveness properties From a theoretical viewpoint we must ensure that we eventually make progress i.e. we want to avoid : blocked threads/processes waiting for each other Livelock: processes/threads execute
More informationIntroduction to Lambda Calculus. Lecture 7 CS /08/09
Introduction to Lambda Calculus Lecture 7 CS 565 02/08/09 Lambda Calculus So far, we ve explored some simple but non-interesting languages language of arithmetic expressions IMP (arithmetic + while loops)
More informationCHAPTER 6: PROCESS SYNCHRONIZATION
CHAPTER 6: PROCESS SYNCHRONIZATION The slides do not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams. TOPICS Background
More informationLecture Notes on Data Representation
Lecture Notes on Data Representation 15-814: Types and Programming Languages Frank Pfenning Lecture 9 Tuesday, October 2, 2018 1 Introduction In this lecture we ll see our type system in action. In particular
More informationThe Deadlock Lecture
Concurrent systems Lecture 4: Deadlock, Livelock, and Priority Inversion DrRobert N. M. Watson The Deadlock Lecture 1 Reminder from last time Multi-Reader Single-Writer (MRSW) locks Alternatives to semaphores/locks:
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 informationLambda Calculus. Variables and Functions. cs3723 1
Lambda Calculus Variables and Functions cs3723 1 Lambda Calculus Mathematical system for functions Computation with functions Captures essence of variable binding Function parameters and substitution Can
More informationCSE 505: Concepts of Programming Languages
CSE 505: Concepts of Programming Languages Dan Grossman Fall 2003 Lecture 6 Lambda Calculus Dan Grossman CSE505 Fall 2003, Lecture 6 1 Where we are Done: Modeling mutation and local control-flow Proving
More informationParallel Processing: Performance Limits & Synchronization
Parallel Processing: Performance Limits & Synchronization Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. May 8, 2018 L22-1 Administrivia Quiz 3: Thursday 7:30-9:30pm, room 50-340
More informationTyping Control. Chapter Conditionals
Chapter 26 Typing Control 26.1 Conditionals Let s expand our language with a conditional construct. We can use if0 like before, but for generality it s going to be more convenient to have a proper conditional
More informationProcess 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 informationChapter 9. Labelled Transition Systems. System Composition. specifications. implementations.
SFWR ENG 3BB4 Software Design 3 Concurrent System Design SFWR ENG 3BB4 Software Design 3 Concurrent System Design 9.9 System Composition Chapter 9 Labelled Transition Systems A system specification is
More informationProgramming Languages Third Edition
Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand
More informationLambda Calculus and Lambda notation in Lisp II. Based on Prof. Gotshalks notes on Lambda Calculus and Chapter 9 in Wilensky.
λ Calculus Basis Lambda Calculus and Lambda notation in Lisp II Based on Prof. Gotshalks notes on Lambda Calculus and Chapter 9 in Wilensky Mathematical theory for anonymous functions» functions that have
More information5 Classical IPC Problems
OPERATING SYSTEMS CLASSICAL IPC PROBLEMS 2 5 Classical IPC Problems The operating systems literature is full of interesting problems that have been widely discussed and analyzed using a variety of synchronization
More informationGraphical Untyped Lambda Calculus Interactive Interpreter
Graphical Untyped Lambda Calculus Interactive Interpreter (GULCII) Claude Heiland-Allen https://mathr.co.uk mailto:claude@mathr.co.uk Edinburgh, 2017 Outline Lambda calculus encodings How to perform lambda
More informationCS 6110 S14 Lecture 1 Introduction 24 January 2014
CS 6110 S14 Lecture 1 Introduction 24 January 2014 1 Introduction What is a program? Is it just something that tells the computer what to do? Yes, but there is much more to it than that. The basic expressions
More informationControl Abstraction. Hwansoo Han
Control Abstraction Hwansoo Han Review of Static Allocation Static allocation strategies Code Global variables Own variables (live within an encapsulation - static in C) Explicit constants (including strings,
More informationEI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)
EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture) Dept. of Computer Science & Engineering Chentao Wu wuct@cs.sjtu.edu.cn Download lectures ftp://public.sjtu.edu.cn User:
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 12 Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ 2 Mutex vs Semaphore Mutex is binary,
More informationCMSC 336: Type Systems for Programming Languages Lecture 4: Programming in the Lambda Calculus Acar & Ahmed 22 January 2008.
CMSC 336: Type Systems for Programming Languages Lecture 4: Programming in the Lambda Calculus Acar & Ahmed 22 January 2008 Contents 1 Announcements 1 2 Solution to the Eercise 1 3 Introduction 1 4 Multiple
More informationAXIOMS OF AN IMPERATIVE LANGUAGE PARTIAL CORRECTNESS WEAK AND STRONG CONDITIONS. THE AXIOM FOR nop
AXIOMS OF AN IMPERATIVE LANGUAGE We will use the same language, with the same abstract syntax that we used for operational semantics. However, we will only be concerned with the commands, since the language
More information1.3. Conditional expressions To express case distinctions like
Introduction Much of the theory developed in the underlying course Logic II can be implemented in a proof assistant. In the present setting this is interesting, since we can then machine extract from a
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 1018 L11 Synchronization Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Multilevel feedback queue:
More informationSoftware Paradigms (Lesson 4) Functional Programming Paradigm
Software Paradigms (Lesson 4) Functional Programming Paradigm Table of Contents 1 Introduction... 2 2 Evaluation of Functions... 3 3 Compositional (Construct) Operators... 4 4 Some Implementation Issues...
More informationLecture 2: SML Basics
15-150 Lecture 2: SML Basics Lecture by Dan Licata January 19, 2012 I d like to start off by talking about someone named Alfred North Whitehead. With someone named Bertrand Russell, Whitehead wrote Principia
More informationChapter 7: Process Synchronization!
Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Monitors 7.1 Background Concurrent access to shared
More informationCS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University
Frequently asked questions from the previous class survey CS 370: SYSTEM ARCHITECTURE & SOFTWARE [PROCESS SYNCHRONIZATION] Shrideep Pallickara Computer Science Colorado State University Semaphores From
More informationLearning Outcomes. Concurrency and Synchronisation. Textbook. Concurrency Example. Inter- Thread and Process Communication. Sections & 2.
Learning Outcomes Concurrency and Synchronisation Understand concurrency is an issue in operating systems and multithreaded applications Know the concept of a critical region. Understand how mutual exclusion
More informationSt. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad
St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad-00 014 Subject: PPL Class : CSE III 1 P a g e DEPARTMENT COMPUTER SCIENCE AND ENGINEERING S No QUESTION Blooms Course taxonomy level Outcomes UNIT-I
More informationCS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers
CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers 1 Critical sections and atomicity We have been seeing that sharing mutable objects between different threads is tricky We need some
More informationFunctional Programming
Functional Programming CS331 Chapter 14 Functional Programming Original functional language is LISP LISt Processing The list is the fundamental data structure Developed by John McCarthy in the 60 s Used
More informationCOMP 1130 Lambda Calculus. based on slides by Jeff Foster, U Maryland
COMP 1130 Lambda Calculus based on slides by Jeff Foster, U Maryland Motivation Commonly-used programming languages are large and complex ANSI C99 standard: 538 pages ANSI C++ standard: 714 pages Java
More informationAn introduction to Scheme
An introduction to Scheme Introduction A powerful programming language is more than just a means for instructing a computer to perform tasks. The language also serves as a framework within which we organize
More information6.001 Notes: Section 6.1
6.001 Notes: Section 6.1 Slide 6.1.1 When we first starting talking about Scheme expressions, you may recall we said that (almost) every Scheme expression had three components, a syntax (legal ways of
More informationLecture 13 CIS 341: COMPILERS
Lecture 13 CIS 341: COMPILERS Announcements HW4: OAT v. 1.0 Parsing & basic code generation Due: March 28 th START EARLY! Midterm Exam Grades Available on Gradescope Zdancewic CIS 341: Compilers 2 Midterm
More informationProcess Synchronization
TDDI04 Concurrent Programming, Operating Systems, and Real-time Operating Systems Process Synchronization [SGG7] Chapter 6 Copyright Notice: The lecture notes are mainly based on Silberschatz s, Galvin
More informationConcurrency and Synchronisation
Concurrency and Synchronisation 1 Learning Outcomes Understand concurrency is an issue in operating systems and multithreaded applications Know the concept of a critical region. Understand how mutual exclusion
More informationConcurrency and Synchronisation
Concurrency and Synchronisation 1 Sections 2.3 & 2.4 Textbook 2 Making Single-Threaded Code Multithreaded Conflicts between threads over the use of a global variable 3 Inter- Thread and Process Communication
More informationFunctional abstraction. What is abstraction? Eating apples. Readings: HtDP, sections Language level: Intermediate Student With Lambda
Functional abstraction Readings: HtDP, sections 19-24. Language level: Intermediate Student With Lambda different order used in lecture section 24 material introduced much earlier sections 22, 23 not covered
More informationFunctional abstraction
Functional abstraction Readings: HtDP, sections 19-24. Language level: Intermediate Student With Lambda different order used in lecture section 24 material introduced much earlier sections 22, 23 not covered
More informationChapter 5 Concurrency: Mutual Exclusion and Synchronization
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 informationMulticore and Multiprocessor Systems: Part I
Chapter 3 Multicore and Multiprocessor Systems: Part I Max Planck Institute Magdeburg Jens Saak, Scientific Computing II 44/342 Symmetric Multiprocessing Definition (Symmetric Multiprocessing (SMP)) he
More informationRoadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - XI Deadlocks - II. Louisiana State University
CSC 4103 - Operating Systems Fall 2009 Lecture - XI Deadlocks - II Tevfik Ko!ar Louisiana State University September 29 th, 2009 1 Roadmap Classic Problems of Synchronization Bounded Buffer Readers-Writers
More information3 Process Synchronization
Lab 2: Process Synchronization Computer Systems DV1 Autumn 2003 Lab Assistant John Håkansson www.docs.uu.se/ johnh email: johnh@docs.uu.se room: 1442 postbox: 136 (4th floor, building 1) phone: 018-471
More information(Refer Slide Time: 4:00)
Principles of Programming Languages Dr. S. Arun Kumar Department of Computer Science & Engineering Indian Institute of Technology, Delhi Lecture - 38 Meanings Let us look at abstracts namely functional
More informationIntro. 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 informationRoadmap. Bounded-Buffer Problem. Classical Problems of Synchronization. Bounded Buffer 1 Semaphore Soln. Bounded Buffer 1 Semaphore Soln. Tevfik Ko!
CSC 4103 - Operating Systems Fall 2009 Lecture - XI Deadlocks - II Roadmap Classic Problems of Synchronization Bounded Buffer Readers-Writers Dining Philosophers Sleeping Barber Deadlock Prevention Tevfik
More informationConcurrency and Synchronisation. Leonid Ryzhyk
Concurrency and Synchronisation Leonid Ryzhyk Textbook Sections 2.3 & 2.5 2 Concurrency in operating systems Inter-process communication web server SQL request DB Intra-process communication worker thread
More informationMultithreaded Programming Part II. CSE 219 Stony Brook University, Department of Computer Science
Multithreaded Programming Part II CSE 219 Stony Brook University, Thread Scheduling In a Java application, main is a thread on its own Once multiple threads are made Runnable the thread scheduler of the
More informationSynchronization Principles II
CSC 256/456: Operating Systems Synchronization Principles II John Criswell University of Rochester 1 Synchronization Issues Race conditions and the need for synchronization Critical Section Problem Mutual
More informationUNIT 3
UNIT 3 Presentation Outline Sequence control with expressions Conditional Statements, Loops Exception Handling Subprogram definition and activation Simple and Recursive Subprogram Subprogram Environment
More informationDeadlocks. Deadlock in Resource Sharing Environment. CIT 595 Spring Recap Example. Representing Deadlock
Deadlock in Resource Sharing Environment Operating System Deadlocks CIT 595 Spring 2010 A deadlock occurs when 2 or more processes/threads permanently block each other by each having a lock on a resource
More informationCS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011
CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e
More informationCPS221 Lecture: Threads
Objectives CPS221 Lecture: Threads 1. To introduce threads in the context of processes 2. To introduce UML Activity Diagrams last revised 9/5/12 Materials: 1. Diagram showing state of memory for a process
More informationINSTITUTE OF AERONAUTICAL ENGINEERING
INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad -500 043 INFORMATION TECHNOLOGY TUTORIAL QUESTION BANK Name : PRINCIPLES OF PROGRAMMING LANGUAGES Code : A40511 Class : II B. Tech
More informationTopics in Object-Oriented Design Patterns
Software design Topics in Object-Oriented Design Patterns Material mainly from the book Design Patterns by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides; slides originally by Spiros Mancoridis;
More informationProcess Synchronization
Chapter 7 Process Synchronization 1 Chapter s Content Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors 2 Background
More informationThreads and Locks. CSCI 5828: Foundations of Software Engineering Lecture 09 09/22/2015
Threads and Locks CSCI 5828: Foundations of Software Engineering Lecture 09 09/22/2015 1 Goals Cover the material presented in Chapter 2, Day 1 of our concurrency textbook Creating threads Locks Memory
More informationConcurrency pros and cons. Concurrent Programming Problems. Linked list example. Linked list example. Mutual Exclusion. Concurrency is good for users
Concurrency pros and cons Con Programming Problems OS Spring 2011 Concurrency is good for users One of the reasons for multiprogramming Working on the same problem, simultaneous execution of programs,
More information15 Unification and Embedded Languages in Lisp
15 Unification and Embedded Languages in Lisp Chapter Objectives Chapter Contents Pattern matching in Lisp: Database examples Full unification as required for Predicate Calculus problem solving Needed
More informationAlan J. Perlis - Epigrams on Programming
Programming Languages (CS302 2007S) Alan J. Perlis - Epigrams on Programming Comments on: Perlis, Alan J. (1982). Epigrams on Programming. ACM SIGPLAN Notices 17(9), September 1982, pp. 7-13. 1. One man
More informationOn Formal Analysis of OO Languages using. OO Languages and Rewriting Logic: Designing for Performance
On Formal Analysis of OO Languages using Rewriting Logic: Designing for Performance {mhills, grosu}@cs.uiuc.edu Department of Computer Science University of Illinois at Urbana-Champaign 6 June 2007 1 2
More informationHigh Performance Computing Prof. Matthew Jacob Department of Computer Science and Automation Indian Institute of Science, Bangalore
High Performance Computing Prof. Matthew Jacob Department of Computer Science and Automation Indian Institute of Science, Bangalore Module No # 09 Lecture No # 40 This is lecture forty of the course on
More informationDeadlock CS 241. March 19, University of Illinois
Deadlock CS 241 March 19, 2014 University of Illinois Slides adapted in part from material accompanying Bryant & O Hallaron, Computer Systems: A Programmer's Perspective, 2/E 1 The Dining Philosophers
More informationObservable Behaviour Observable behaviour can be defined in terms of experimentation.
Observable Behaviour Observable behaviour can be defined in terms of experimentation. Consider a coffee machine. We don t need to understand and don t what to understand how the coffee machine works. All
More information