CS 3411 Systems Programming

Size: px
Start display at page:

Download "CS 3411 Systems Programming"

Transcription

1 CS 3411 Systems Programming Department of Computer Science Michigan Technological University Pipe Inter-Process Communication in Unix

2 Today's Topics How to communicate between processes without using signals Creating and Using Pipes

3 How to Communicate Between Processes Have two primitive mechanisms in hand: exit/wait signals The sample program we'll be working on: Parent creates child Send child an int, x Child computes 2x and returns result Maybe a loop that keeps doing this! Parent and child share no memory; i.e. no common variables through which to communicate

4 How to Communicate Between Processes Parent and child share open le descriptors, even after fork() or fork()/exec() Proposed solution: Parent opens les, forks child Child arranges descriptors with close and dup, execs new binary Parent and child communicate via read()/write() on shared le

5 Example Code #i n c l u d e < f c n t l. h> #i n c l u d e <s t d i o. h> #i n c l u d e <s y s / t y p e s. h> #i n c l u d e <u n i s t d. h> #i n c l u d e < s t d l i b. h> main ( ) { i n t fd, v a l, d b l v a l ; f d = open ( " commofile ", O_RDWR O_CREAT O_TRUNC, ) ; i f ( f o r k ( ) == 0) { / CHILD / r e a d ( fd, &v a l, s i z e o f ( i n t ) ) ; l s e e k ( fd, 0, SEEK_SET ) ; d b l v a l = 2 v a l ; w r i t e ( fd, &d b l v a l, s i z e o f ( i n t ) ) ; l s e e k ( fd, 0, SEEK_SET ) ; e x i t ( 0 ) ; e l s e { / PARENT / v a l = 2 ; f p r i n t f ( s t d e r r, " Asking c h i l d to d o u b l e %d\n", v a l ) ; w r i t e ( fd, &v a l, s i z e o f ( i n t ) ) ; l s e e k ( fd, 0, SEEK_SET ) ; r e a d ( fd, &d b l v a l, s i z e o f ( i n t ) ) ; f p r i n t f ( s t d e r r, " C h i l d r e p l i e d w i t h %d\n", d b l v a l ) ; w a i t (NULL ) ; e x i t ( 0 ) ;

6 Results Why did it turn out like that? Fundamental problem: Need more control over access to the shared le Specically, read from an empty le (or read when currency indicator is at EOF) should delay caller until data is available to read The Unix solution is a construct called a pipe

7 The pipe() System Call The pipe() function takes one argument in the form of an array with 2 elements The rst element is the read end of the pipe The second element is the write end of the pipe Data written to the pipe is buered by the kernel until it is read

8 Pipes Can think of a pipe as an unnamed, xed length le maintained by the kernel We also looked at the named versions! They're identical once opened - no data is to the device in either case! Pipes have separate le descriptors as well as currency indicators for reading and writing Some special properties: A read from a pipe that doesn't have sucient data to satisfy the read will block the reader until the data is available A write to a pipe that is full will delay the writer until space becomes available From a reader's perspective, EOF can only happen if there is no data in the pipe and all write descriptors on the pipe are closed From a writer's perspective, an attempt to write to a pipe without live read descriptors will result in a SIGPIPE signal being sent to the writer

9 Example Code #i n c l u d e < f c n t l. h> #i n c l u d e <s t d i o. h> #i n c l u d e <s y s / t y p e s. h> #i n c l u d e <u n i s t d. h> #i n c l u d e < s t d l i b. h> i n t f d [ 2 ], v a l = 0, d b l v a l = 0 ; main ( ) { p i p e ( f d ) ; i f ( f o r k ( ) == 0) { / CHILD / w h i l e ( r e a d ( f d [ 0 ], &v a l, s i z e o f ( i n t ) )!= 0) { d b l v a l = 2 v a l ; w r i t e ( f d [ 1 ], &d b l v a l, s i z e o f ( i n t ) ) ; e x i t ( 0 ) ; e l s e { / PARENT / f o r ( v a l = 1 ; v a l <= 3 ; v a l ++) { f p r i n t f ( s t d e r r, " Asking c h i l d to d o u b l e %d\n", v a l ) ; w r i t e ( f d [ 1 ], &v a l, s i z e o f ( i n t ) ) ; r e a d ( f d [ 0 ], &d b l v a l, s i z e o f ( i n t ) ) ; f p r i n t f ( s t d e r r, " C h i l d r e p l i e d w i t h %d\n", d b l v a l ) ; w a i t (NULL ) ;

10 Results What now? Another problem: Pipe is essentially a construct for unidirectional transfer of information. Parent is reading its own data written into the pipe. Need one pipe for synchronized parent-to-child communication And a second pipe for synchronized child-to-parent communication When do we get EOF?

11 Example Code #i n c l u d e < f c n t l. h> #i n c l u d e <s t d i o. h> #i n c l u d e <s y s / t y p e s. h> #i n c l u d e <u n i s t d. h> #i n c l u d e < s t d l i b. h> i n t p2c [ 2 ], c2p [ 2 ], v a l = 0, d b l v a l = 0 ; main ( ) { p i p e ( p2c ) ; p i p e ( c2p ) ; i f ( f o r k ( ) == 0) { / CHILD / c l o s e ( p2c [ 1 ] ) ; c l o s e ( c2p [ 0 ] ) ; w h i l e ( r e a d ( p2c [ 0 ], &v a l, s i z e o f ( i n t ) )!= 0) { d b l v a l = 2 v a l ; w r i t e ( c2p [ 1 ], &d b l v a l, s i z e o f ( i n t ) ) ; e x i t ( 0 ) ; e l s e { / PARENT / c l o s e ( c2p [ 1 ] ) ; c l o s e ( p2c [ 0 ] ) ; f o r ( v a l = 1 ; v a l <= 3 ; v a l ++) { f p r i n t f ( s t d e r r, " Asking c h i l d to d o u b l e %d\n", v a l ) ; w r i t e ( p2c [ 1 ], &v a l, s i z e o f ( i n t ) ) ; r e a d ( c2p [ 0 ], &d b l v a l, s i z e o f ( i n t ) ) ; f p r i n t f ( s t d e r r, " C h i l d r e p l i e d w i t h %d\n", d b l v a l ) ; c l o s e ( p2c [ 1 ] ) ; c l o s e ( c2p [ 0 ] ) ; w a i t (NULL ) ;

12 Results It works as expected this time! Let's take a look at some other examples

13 Real Examples I #i n c l u d e < f c n t l. h> #i n c l u d e <s t d i o. h> #i n c l u d e <s y s / t y p e s. h> #i n c l u d e <u n i s t d. h> #i n c l u d e < s t d l i b. h> / We want to e x e c u t e " ps aux g r e p r o o t " / main ( ) { i n t i s P a r e n t ; i n t a p i p e [ 2 ] ; char cmd [ 2 ] [ 3 ] ; cmd [ 0 ] [ 0 ] = " ps " ; cmd [ 0 ] [ 1 ] = " aux " ; cmd [ 0 ] [ 2 ] = NULL ; cmd [ 1 ] [ 0 ] = " g r e p " ; cmd [ 1 ] [ 1 ] = " r o o t " ; cmd [ 1 ] [ 2 ] = NULL ; p i p e ( a p i p e ) ; i s P a r e n t = f o r k ( ) ; i f (! i s P a r e n t ) { / C h i l d i s g o i n g to be " g r e p r o o t " / / We want s t d i n c o n n e c t e d to our p i p e! / c l o s e ( a p i p e [ 1 ] ) ; c l o s e ( 0 ) ; dup ( a p i p e [ 0 ] ) ; c l o s e ( a p i p e [ 0 ] ) ;

14 Real Examples II e x ecvp (cmd [ 1 ] [ 0 ], cmd [ 1 ] ) ; p e r r o r ( " C h i l d e x e c : : " ) ; e x i t ( 1 ) ; e l s e { / Parent i s " ps aux " / / We want t h e s t d o u t c o n n e c t e d to p i p e / c l o s e ( a p i p e [ 0 ] ) ; c l o s e ( 1 ) ; dup ( a p i p e [ 1 ] ) ; c l o s e ( a p i p e [ 1 ] ) ; e x ecvp (cmd [ 0 ] [ 0 ], cmd [ 0 ] ) ; p e r r o r ( " Parent e x e c : : " ) ; e x i t ( 1 ) ;

15 Real Examples I #i n c l u d e < f c n t l. h> #i n c l u d e <s t d i o. h> #i n c l u d e <s y s / t y p e s. h> #i n c l u d e <u n i s t d. h> #i n c l u d e < s t d l i b. h> / We want to e x e c u t e " s o r t < filecomm1. c g r e p f p r i n t f wc" / main ( ) { i n t a p i p e [ 2 ] ; i n t i s P a r e n t ; char cmd [ 3 ] [ 3 ] ; i n t i, l a s t C h i l d, fd, s a v e S t d o u t ; cmd [ 0 ] [ 0 ] = " s o r t " ; cmd [ 0 ] [ 1 ] = NULL ; cmd [ 1 ] [ 0 ] = " g r e p " ; cmd [ 1 ] [ 1 ] = " f p r i n t f " ; cmd [ 1 ] [ 2 ] = NULL ; cmd [ 2 ] [ 0 ] = "wc" ; cmd [ 2 ] [ 1 ] = NULL ; s a v e S t d o u t = dup ( 1 ) ; f o r ( i = 2 ; i >= 0 ; i ) { p i p e ( a p i p e ) ; i s P a r e n t = f o r k ( ) ; i f (! i s P a r e n t ) { c l o s e ( a p i p e [ 1 ] ) ; c l o s e ( 0 ) ; i f ( i!= 0) { dup ( a p i p e [ 0 ] ) ;

16 Real Examples II i f ( i == 0) { f d = open ( " filecomm1. c ", O_RDONLY) ; dup ( f d ) ; c l o s e ( a p i p e [ 0 ] ) ; e x ecvp (cmd [ i ] [ 0 ], cmd [ i ] ) ; e x i t ( 1 ) ; e l s e { i f ( i ==2) l a s t C h i l d = i s P a r e n t ; c l o s e ( a p i p e [ 0 ] ) ; c l o s e ( 1 ) ; i f ( i!=0) { dup ( a p i p e [ 1 ] ) ; c l o s e ( a p i p e [ 1 ] ) ; i f ( i ==0){ dup2 ( s a v estdout, 1 ) ; w a i t p i d ( l a s t C h i l d, NULL, 0 ) ;

CS 3411 Systems Programming

CS 3411 Systems Programming CS 3411 Systems Programming Department of Computer Science Michigan Technological University Unix Processes Today s Topics Unix Processes Creating New Processes Unix Processes Process is the image of a

More information

CS 3411 Systems Programming

CS 3411 Systems Programming CS 3411 Systems Programming Department of Computer Science Michigan Technological University Sockets Today's Topics New Way of Communicating Between Processes Sockets Standard" Unix Processes/IPC IPC stands

More information

Socket Programming. Daniel Zappala. CS 360 Internet Programming Brigham Young University

Socket Programming. Daniel Zappala. CS 360 Internet Programming Brigham Young University Socket Programming Daniel Zappala CS 360 Internet Programming Brigham Young University Sockets, Addresses, Ports Clients and Servers 3/33 clients request a service from a server using a protocol need an

More information

Counters. We ll look at different kinds of counters and discuss how to build them

Counters. We ll look at different kinds of counters and discuss how to build them Counters We ll look at different kinds of counters and discuss how to build them These are not only examples of sequential analysis and design, but also real devices used in larger circuits 1 Introducing

More information

Notes on Paths, Trees and Lagrange Inversion

Notes on Paths, Trees and Lagrange Inversion Notes on Paths, Trees and Lagrange Inversion Today we are going to start with a problem that may seem somewhat unmotivated, and solve it in two ways. From there, we will proceed to discuss applications

More information

INF Models of concurrency

INF Models of concurrency Monitors INF4140 - Models of concurrency Monitors, lecture 4 Fall 2017 27. September 2017 2 / 49 Overview Concurrent execution of different processes Communication by shared variables Processes may interfere

More information

The Bell-LaPadula Model

The Bell-LaPadula Model The Bell-LaPadula Model CSM27 Computer Security Dr Hans Georg Schaathun University of Surrey Autumn 2007 Dr Hans Georg Schaathun The Bell-LaPadula Model Autumn 2007 1 / 25 The session Session objectives

More information

I/O Devices. Device. Lecture Notes Week 8

I/O Devices. Device. Lecture Notes Week 8 I/O Devices CPU PC ALU System bus Memory bus Bus interface I/O bridge Main memory USB Graphics adapter I/O bus Disk other devices such as network adapters Mouse Keyboard Disk hello executable stored on

More information

INF Models of concurrency

INF Models of concurrency INF4140 - Models of concurrency RPC and Rendezvous INF4140 Lecture 15. Nov. 2017 RPC and Rendezvous Outline More on asynchronous message passing interacting processes with different patterns of communication

More information

INF2220: algorithms and data structures Series 1

INF2220: algorithms and data structures Series 1 Universitetet i Oslo Institutt for Informatikk I. Yu, D. Karabeg INF2220: algorithms and data structures Series 1 Topic Function growth & estimation of running time, trees (Exercises with hints for solution)

More information

Recurrent Neural Networks

Recurrent Neural Networks Recurrent Neural Networks Datamining Seminar Kaspar Märtens Karl-Oskar Masing Today's Topics Modeling sequences: a brief overview Training RNNs with back propagation A toy example of training an RNN Why

More information

10:00 12:30. Do not open this problem booklet until the start of the examination is announced.

10:00 12:30. Do not open this problem booklet until the start of the examination is announced. 21 I 20 8 26 10:00 12:30 (1),. Do not open this problem booklet until the start of the examination is announced. (2) 4.. Answer the following 4 problems. Use the designated answer sheet for each problem.

More information

How to Pop a Deep PDA Matters

How to Pop a Deep PDA Matters How to Pop a Deep PDA Matters Peter Leupold Department of Mathematics, Faculty of Science Kyoto Sangyo University Kyoto 603-8555, Japan email:leupold@cc.kyoto-su.ac.jp Abstract Deep PDA are push-down automata

More information

Part I. System call overview. Secure Operating System Design and Implementation System Calls. Overview. Abstraction. Jon A. Solworth.

Part I. System call overview. Secure Operating System Design and Implementation System Calls. Overview. Abstraction. Jon A. Solworth. Secure Operating System Design and Implementation System Calls Jon A. Solworth Part I System call overview Dept. of Computer Science University of Illinois at Chicago February 1, 2011 Overview Abstraction

More information

Valency Arguments CHAPTER7

Valency Arguments CHAPTER7 CHAPTER7 Valency Arguments In a valency argument, configurations are classified as either univalent or multivalent. Starting from a univalent configuration, all terminating executions (from some class)

More information

Agreement. Today. l Coordination and agreement in group communication. l Consensus

Agreement. Today. l Coordination and agreement in group communication. l Consensus Agreement Today l Coordination and agreement in group communication l Consensus Events and process states " A distributed system a collection P of N singlethreaded processes w/o shared memory Each process

More information

Lower bound for sorting/probability Distributions

Lower bound for sorting/probability Distributions Lower bound for sorting/probability Distributions CSE21 Winter 2017, Day 20 (B00), Day 14 (A00) March 3, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Another application of counting lower bounds Sorting

More information

CS 151. Red Black Trees & Structural Induction. Thursday, November 1, 12

CS 151. Red Black Trees & Structural Induction. Thursday, November 1, 12 CS 151 Red Black Trees & Structural Induction 1 Announcements Majors fair tonight 4:30-6:30pm in the Root Room in Carnegie. Come and find out about the CS major, or some other major. Winter Term in CS

More information

Bounding the End-to-End Response Times of Tasks in a Distributed. Real-Time System Using the Direct Synchronization Protocol.

Bounding the End-to-End Response Times of Tasks in a Distributed. Real-Time System Using the Direct Synchronization Protocol. Bounding the End-to-End Response imes of asks in a Distributed Real-ime System Using the Direct Synchronization Protocol Jun Sun Jane Liu Abstract In a distributed real-time system, a task may consist

More information

Concurrent HTTP Proxy Server. CS425 - Computer Networks Vaibhav Nagar(14785)

Concurrent HTTP Proxy Server. CS425 - Computer Networks Vaibhav Nagar(14785) Concurrent HTTP Proxy Server CS425 - Computer Networks Vaibhav Nagar(14785) Email: vaibhavn@iitk.ac.in August 31, 2016 Elementary features of Proxy Server Proxy server supports the GET method to serve

More information

Announcements. CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis. Today. Mathematical induction. Dan Grossman Spring 2010

Announcements. CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis. Today. Mathematical induction. Dan Grossman Spring 2010 Announcements CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis Dan Grossman Spring 2010 Project 1 posted Section materials on using Eclipse will be very useful if you have never used

More information

Waves, electricity, light, and the atom

Waves, electricity, light, and the atom Waves, electricity, light, and the atom Objectives Use an interactive digital keyboard to observe different frequency sound waves. Investigate and analyze the frequency of sound waves. Assessment 1. Name

More information

Fairfield Public Schools Science Curriculum Draft Units Physics 40

Fairfield Public Schools Science Curriculum Draft Units Physics 40 Fairfield Public Schools Science Curriculum Draft Units Physics 40 1 Course: Description The study of natural phenomena and interactions between matter and energy using mathematical models and laws to

More information

Topic 17. Analysis of Algorithms

Topic 17. Analysis of Algorithms Topic 17 Analysis of Algorithms Analysis of Algorithms- Review Efficiency of an algorithm can be measured in terms of : Time complexity: a measure of the amount of time required to execute an algorithm

More information

Sequential Logic (3.1 and is a long difficult section you really should read!)

Sequential Logic (3.1 and is a long difficult section you really should read!) EECS 270, Fall 2014, Lecture 6 Page 1 of 8 Sequential Logic (3.1 and 3.2. 3.2 is a long difficult section you really should read!) One thing we have carefully avoided so far is feedback all of our signals

More information

CS 310 Advanced Data Structures and Algorithms

CS 310 Advanced Data Structures and Algorithms CS 310 Advanced Data Structures and Algorithms Runtime Analysis May 31, 2017 Tong Wang UMass Boston CS 310 May 31, 2017 1 / 37 Topics Weiss chapter 5 What is algorithm analysis Big O, big, big notations

More information

Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn

Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn Priority Queue / Heap Stores (key,data) pairs (like dictionary) But, different set of operations: Initialize-Heap: creates new empty heap

More information

A version of for which ZFC can not predict a single bit Robert M. Solovay May 16, Introduction In [2], Chaitin introd

A version of for which ZFC can not predict a single bit Robert M. Solovay May 16, Introduction In [2], Chaitin introd CDMTCS Research Report Series A Version of for which ZFC can not Predict a Single Bit Robert M. Solovay University of California at Berkeley CDMTCS-104 May 1999 Centre for Discrete Mathematics and Theoretical

More information

Memory Elements I. CS31 Pascal Van Hentenryck. CS031 Lecture 6 Page 1

Memory Elements I. CS31 Pascal Van Hentenryck. CS031 Lecture 6 Page 1 Memory Elements I CS31 Pascal Van Hentenryck CS031 Lecture 6 Page 1 Memory Elements (I) Combinational devices are good for computing Boolean functions pocket calculator Computers also need to remember

More information

CS 6112 (Fall 2011) Foundations of Concurrency

CS 6112 (Fall 2011) Foundations of Concurrency CS 6112 (Fall 2011) Foundations of Concurrency 29 November 2011 Scribe: Jean-Baptiste Jeannin 1 Readings The readings for today were: Eventually Consistent Transactions, by Sebastian Burckhardt, Manuel

More information

Analysis of Bounds on Hybrid Vector Clocks

Analysis of Bounds on Hybrid Vector Clocks Analysis of Bounds on Hybrid Vector Clocks Sorrachai Yingchareonthawornchai 1, Sandeep Kulkarni 2, and Murat Demirbas 3 Michigan State University 1,2 University at Buffalo 3 (OPODIS 2015) Motivation A

More information

Fault-Tolerant Consensus

Fault-Tolerant Consensus Fault-Tolerant Consensus CS556 - Panagiota Fatourou 1 Assumptions Consensus Denote by f the maximum number of processes that may fail. We call the system f-resilient Description of the Problem Each process

More information

Genuine atomic multicast in asynchronous distributed systems

Genuine atomic multicast in asynchronous distributed systems Theoretical Computer Science 254 (2001) 297 316 www.elsevier.com/locate/tcs Genuine atomic multicast in asynchronous distributed systems Rachid Guerraoui, Andre Schiper Departement d Informatique, Ecole

More information

Algorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February)

Algorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February) Algorithms and Data Structures 016 Week 5 solutions (Tues 9th - Fri 1th February) 1. Draw the decision tree (under the assumption of all-distinct inputs) Quicksort for n = 3. answer: (of course you should

More information

CS Data Structures and Algorithm Analysis

CS Data Structures and Algorithm Analysis CS 483 - Data Structures and Algorithm Analysis Lecture VII: Chapter 6, part 2 R. Paul Wiegand George Mason University, Department of Computer Science March 22, 2006 Outline 1 Balanced Trees 2 Heaps &

More information

Systems of Linear Equations

Systems of Linear Equations LECTURE 6 Systems of Linear Equations You may recall that in Math 303, matrices were first introduced as a means of encapsulating the essential data underlying a system of linear equations; that is to

More information

Reading: Karlin and Taylor Ch. 5 Resnick Ch. 3. A renewal process is a generalization of the Poisson point process.

Reading: Karlin and Taylor Ch. 5 Resnick Ch. 3. A renewal process is a generalization of the Poisson point process. Renewal Processes Wednesday, December 16, 2015 1:02 PM Reading: Karlin and Taylor Ch. 5 Resnick Ch. 3 A renewal process is a generalization of the Poisson point process. The Poisson point process is completely

More information

Mathematical Background. Unsigned binary numbers. Powers of 2. Logs and exponents. Mathematical Background. Today, we will review:

Mathematical Background. Unsigned binary numbers. Powers of 2. Logs and exponents. Mathematical Background. Today, we will review: Mathematical Background Mathematical Background CSE 373 Data Structures Today, we will review: Logs and eponents Series Recursion Motivation for Algorithm Analysis 5 January 007 CSE 373 - Math Background

More information

1 Introduction. Uri Abraham, Ben-Gurion University, Beer-Sheva, Israel

1 Introduction. Uri Abraham, Ben-Gurion University, Beer-Sheva, Israel ASSERTIONAL AND BEHAVIORAL APPROACHES TO CONCURRENCY Uri Abraham, Ben-Gurion University, Beer-Sheva, Israel Abstract We compare two proofs of the mutual-exclusion property of the well known critical section

More information

Numerical solution of Nash-equilibrium Discreet version: game.r

Numerical solution of Nash-equilibrium Discreet version: game.r Numerical solution of Nash-equilibrium Discreet version: game.r Lars j. Ravn-Jonsen June 2, 2009 This paper documents the program fund in game.r. for numerical game theoretic solutions of discreet games.

More information

INF 4140: Models of Concurrency Series 3

INF 4140: Models of Concurrency Series 3 Universitetet i Oslo Institutt for Informatikk PMA Olaf Owe, Martin Steffen, Toktam Ramezani INF 4140: Models of Concurrency Høst 2016 Series 3 14. 9. 2016 Topic: Semaphores (Exercises with hints for solution)

More information

Degradable Agreement in the Presence of. Byzantine Faults. Nitin H. Vaidya. Technical Report #

Degradable Agreement in the Presence of. Byzantine Faults. Nitin H. Vaidya. Technical Report # Degradable Agreement in the Presence of Byzantine Faults Nitin H. Vaidya Technical Report # 92-020 Abstract Consider a system consisting of a sender that wants to send a value to certain receivers. Byzantine

More information

Discrete Mathematics. CS204: Spring, Jong C. Park Computer Science Department KAIST

Discrete Mathematics. CS204: Spring, Jong C. Park Computer Science Department KAIST Discrete Mathematics CS204: Spring, 2008 Jong C. Park Computer Science Department KAIST Today s Topics Sequential Circuits and Finite-State Machines Finite-State Automata Languages and Grammars Nondeterministic

More information

Real Time Operating Systems

Real Time Operating Systems Real Time Operating ystems Luca Abeni luca.abeni@unitn.it Interacting Tasks Until now, only independent tasks... A job never blocks or suspends A task only blocks on job termination In real world, jobs

More information

CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, Name:

CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, Name: CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, 2017 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : If a child overrides

More information

CPSC 320 Sample Solution, The Stable Marriage Problem

CPSC 320 Sample Solution, The Stable Marriage Problem CPSC 320 Sample Solution, The Stable Marriage Problem September 10, 2016 This is a sample solution that illustrates how we might solve parts of this worksheet. Your answers may vary greatly from ours and

More information

Lecture 4: Process Management

Lecture 4: Process Management Lecture 4: Process Management Process Revisited 1. What do we know so far about Linux on X-86? X-86 architecture supports both segmentation and paging. 48-bit logical address goes through the segmentation

More information

Data Structures. Outline. Introduction. Andres Mendez-Vazquez. December 3, Data Manipulation Examples

Data Structures. Outline. Introduction. Andres Mendez-Vazquez. December 3, Data Manipulation Examples Data Structures Introduction Andres Mendez-Vazquez December 3, 2015 1 / 53 Outline 1 What the Course is About? Data Manipulation Examples 2 What is a Good Algorithm? Sorting Example A Naive Algorithm Counting

More information

Probability Propagation in Singly Connected Networks

Probability Propagation in Singly Connected Networks Lecture 4 Probability Propagation in Singly Connected Networks Intelligent Data Analysis and Probabilistic Inference Lecture 4 Slide 1 Probability Propagation We will now develop a general probability

More information

Consensus when failstop doesn't hold

Consensus when failstop doesn't hold Consensus when failstop doesn't hold FLP shows that can't solve consensus in an asynchronous system with no other facility. It can be solved with a perfect failure detector. If p suspects q then q has

More information

Shift Register Counters

Shift Register Counters Shift Register Counters Shift register counter: a shift register with the serial output connected back to the serial input. They are classified as counters because they give a specified sequence of states.

More information

Fibonacci (Min-)Heap. (I draw dashed lines in place of of circular lists.) 1 / 17

Fibonacci (Min-)Heap. (I draw dashed lines in place of of circular lists.) 1 / 17 Fibonacci (Min-)Heap A forest of heap-order trees (parent priority child priority). Roots in circular doubly-linked list. Pointer to minimum-priority root. Siblings in circular doubly-linked list; parent

More information

Real Time Operating Systems

Real Time Operating Systems Real Time Operating ystems hared Resources Luca Abeni Credits: Luigi Palopoli, Giuseppe Lipari, and Marco Di Natale cuola uperiore ant Anna Pisa -Italy Real Time Operating ystems p. 1 Interacting Tasks

More information

Electric Current Model-Evidence Link Diagram (MEL)

Electric Current Model-Evidence Link Diagram (MEL) A C o n t e n t S e c o n d a r y S c i e n c e N e w s l e t t e r f r o m t h e Southo u t h ern r n Nevada e v a d a R egional g i o n a l Professional r o f e s s i o n a l Development e v e l o p

More information

Lecture 4: Probability Propagation in Singly Connected Bayesian Networks

Lecture 4: Probability Propagation in Singly Connected Bayesian Networks Lecture 4: Probability Propagation in Singly Connected Bayesian Networks Singly Connected Networks So far we have looked at several cases of probability propagation in networks. We now want to formalise

More information

Theoretical Cryptography, Lecture 10

Theoretical Cryptography, Lecture 10 Theoretical Cryptography, Lecture 0 Instructor: Manuel Blum Scribe: Ryan Williams Feb 20, 2006 Introduction Today we will look at: The String Equality problem, revisited What does a random permutation

More information

and The important theorem which connects these various spaces with each other is the following: (with the notation above)

and The important theorem which connects these various spaces with each other is the following: (with the notation above) When F : U V is a linear transformation there are two special subspaces associated to F which are very important. One is a subspace of U and the other is a subspace of V. They are: kerf U (the kernel of

More information

Correctness of Concurrent Programs

Correctness of Concurrent Programs Correctness of Concurrent Programs Trifon Ruskov ruskov@tu-varna.acad.bg Technical University of Varna - Bulgaria Correctness of Concurrent Programs Correctness of concurrent programs needs to be formalized:

More information

Design of Optimized Quantum-dot Cellular Automata RS Flip Flops

Design of Optimized Quantum-dot Cellular Automata RS Flip Flops Int. J. Nanosci. Nanotechnol., Vol. 13, No. 1, March. 2017, pp. 53-58 Design of Optimized Quantum-dot Cellular Automata RS Flip Flops A. Rezaei* 1 Electrical Engineering Department, Kermanshah University

More information

Statistics for Engineers

Statistics for Engineers Statistics for Engineers Antony Lewis http://cosmologist.info/teaching/stat/ Starter question Have you previously done any statistics? 1. Yes 2. No 54% 46% 1 2 BOOKS Chatfield C, 1989. Statistics for

More information

(Refer Slide Time: 0:21)

(Refer Slide Time: 0:21) Theory of Computation Prof. Somenath Biswas Department of Computer Science and Engineering Indian Institute of Technology Kanpur Lecture 7 A generalisation of pumping lemma, Non-deterministic finite automata

More information

Due dates are as mentioned above. Checkoff interviews for PS4 and PS5 will happen together between October 24 and 28, 2012.

Due dates are as mentioned above. Checkoff interviews for PS4 and PS5 will happen together between October 24 and 28, 2012. Problem Set 5 Your answers will be graded by actual human beings (at least that's what we believe!), so don't limit your answers to machine-gradable responses. Some of the questions specifically ask for

More information

CSCI 2150 Intro to State Machines

CSCI 2150 Intro to State Machines CSCI 2150 Intro to State Machines Topic: Now that we've created flip-flops, let's make stuff with them Reading: igital Fundamentals sections 6.11 and 9.4 (ignore the JK flip-flop stuff) States Up until

More information

Einstein s theory of special relativity

Einstein s theory of special relativity Einstein s theory of special relativity Announcements: First homework assignment is online, but you will need to read about time dilation to answer problem #3 and for the definition of ~for problems #4

More information

Spiking Neural P Systems with Anti-Spikes as Transducers

Spiking Neural P Systems with Anti-Spikes as Transducers ROMANIAN JOURNAL OF INFORMATION SCIENCE AND TECHNOLOGY Volume 14, Number 1, 2011, 20 30 Spiking Neural P Systems with Anti-Spikes as Transducers Venkata Padmavati METTA 1, Kamala KRITHIVASAN 2, Deepak

More information

Summary of the Materials Science Classroom Kit lessons and the inclusion of Next Generation Science Standards (NGSS)

Summary of the Materials Science Classroom Kit lessons and the inclusion of Next Generation Science Standards (NGSS) Summary of the Materials Science Classroom Kit lessons and the inclusion of Next Generation Science Standards (NGSS) The framework of the NGSS is three dimensional and includes core ideas (physical sciences,

More information

6. How Functions Work and Are Accessed. Topics: Modules and Functions More on Importing Call Frames

6. How Functions Work and Are Accessed. Topics: Modules and Functions More on Importing Call Frames 6. How Functions Work and Are Accessed Topics: Modules and Functions More on Importing Call Frames Let s Talk About Modules What Are They? M1.py A module is a.py file that contains Python code The name

More information

searching algorithms

searching algorithms searching algorithms learning objectives algorithms your software system software hardware learn what the searching problem is about learn two algorithms for solving this problem learn the importance of

More information

CPSC 320 Sample Solution, Reductions and Resident Matching: A Residentectomy

CPSC 320 Sample Solution, Reductions and Resident Matching: A Residentectomy CPSC 320 Sample Solution, Reductions and Resident Matching: A Residentectomy August 25, 2017 A group of residents each needs a residency in some hospital. A group of hospitals each need some number (one

More information

CSC 5170: Theory of Computational Complexity Lecture 4 The Chinese University of Hong Kong 1 February 2010

CSC 5170: Theory of Computational Complexity Lecture 4 The Chinese University of Hong Kong 1 February 2010 CSC 5170: Theory of Computational Complexity Lecture 4 The Chinese University of Hong Kong 1 February 2010 Computational complexity studies the amount of resources necessary to perform given computations.

More information

Divide-and-Conquer Algorithms Part Two

Divide-and-Conquer Algorithms Part Two Divide-and-Conquer Algorithms Part Two Recap from Last Time Divide-and-Conquer Algorithms A divide-and-conquer algorithm is one that works as follows: (Divide) Split the input apart into multiple smaller

More information

CMPUT 675: Approximation Algorithms Fall 2014

CMPUT 675: Approximation Algorithms Fall 2014 CMPUT 675: Approximation Algorithms Fall 204 Lecture 25 (Nov 3 & 5): Group Steiner Tree Lecturer: Zachary Friggstad Scribe: Zachary Friggstad 25. Group Steiner Tree In this problem, we are given a graph

More information

C++ For Science and Engineering Lecture 17

C++ For Science and Engineering Lecture 17 C++ For Science and Engineering Lecture 17 John Chrispell Tulane University Monday October 4, 2010 Functions and C-Style Strings Three methods for representing the C-style string: An array of char A quoted

More information

Today. Vector Clocks and Distributed Snapshots. Motivation: Distributed discussion board. Distributed discussion board. 1. Logical Time: Vector clocks

Today. Vector Clocks and Distributed Snapshots. Motivation: Distributed discussion board. Distributed discussion board. 1. Logical Time: Vector clocks Vector Clocks and Distributed Snapshots Today. Logical Time: Vector clocks 2. Distributed lobal Snapshots CS 48: Distributed Systems Lecture 5 Kyle Jamieson 2 Motivation: Distributed discussion board Distributed

More information

1. Introduction Bottom-Up-Heapsort is a variant of the classical Heapsort algorithm due to Williams ([Wi64]) and Floyd ([F64]) and was rst presented i

1. Introduction Bottom-Up-Heapsort is a variant of the classical Heapsort algorithm due to Williams ([Wi64]) and Floyd ([F64]) and was rst presented i A Tight Lower Bound for the Worst Case of Bottom-Up-Heapsort 1 by Rudolf Fleischer 2 Keywords : heapsort, bottom-up-heapsort, tight lower bound ABSTRACT Bottom-Up-Heapsort is a variant of Heapsort. Its

More information

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors CSC258 Week 3 1 Logistics If you cannot login to MarkUs, email me your UTORID and name. Check lab marks on MarkUs, if it s recorded wrong, contact Larry within a week after the lab. Quiz 1 average: 86%

More information

CS 5321: Advanced Algorithms Amortized Analysis of Data Structures. Motivations. Motivation cont d

CS 5321: Advanced Algorithms Amortized Analysis of Data Structures. Motivations. Motivation cont d CS 5321: Advanced Algorithms Amortized Analysis of Data Structures Ali Ebnenasir Department of Computer Science Michigan Technological University Motivations Why amortized analysis and when? Suppose you

More information

CS 361: Probability & Statistics

CS 361: Probability & Statistics February 12, 2018 CS 361: Probability & Statistics Random Variables Monty hall problem Recall the setup, there are 3 doors, behind two of them are indistinguishable goats, behind one is a car. You pick

More information

Probability Distributions. Conditional Probability.

Probability Distributions. Conditional Probability. Probability Distributions. Conditional Probability. CSE21 Winter 2017, Day 21 (B00), Day 14 (A00) March 6, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Probability Rosen p. 446, 453 Sample space, S:

More information

Distributed Systems. Time, clocks, and Ordering of events. Rik Sarkar. University of Edinburgh Spring 2018

Distributed Systems. Time, clocks, and Ordering of events. Rik Sarkar. University of Edinburgh Spring 2018 Distributed Systems Time, clocks, and Ordering of events Rik Sarkar University of Edinburgh Spring 2018 Notes Today: Time, clocks, NTP Ref: CDK Causality, ordering, logical clocks: Ref: VG, CDK Time Ordering

More information

LECTURES 14/15: LINEAR INDEPENDENCE AND BASES

LECTURES 14/15: LINEAR INDEPENDENCE AND BASES LECTURES 14/15: LINEAR INDEPENDENCE AND BASES MA1111: LINEAR ALGEBRA I, MICHAELMAS 2016 1. Linear Independence We have seen in examples of span sets of vectors that sometimes adding additional vectors

More information

jflap demo Regular expressions Pumping lemma Turing Machines Sections 12.4 and 12.5 in the text

jflap demo Regular expressions Pumping lemma Turing Machines Sections 12.4 and 12.5 in the text On the menu today jflap demo Regular expressions Pumping lemma Turing Machines Sections 12.4 and 12.5 in the text 1 jflap Demo jflap: Useful tool for creating and testing abstract machines Finite automata,

More information

Section 6 Fault-Tolerant Consensus

Section 6 Fault-Tolerant Consensus Section 6 Fault-Tolerant Consensus CS586 - Panagiota Fatourou 1 Description of the Problem Consensus Each process starts with an individual input from a particular value set V. Processes may fail by crashing.

More information

More Example Using Loops

More Example Using Loops Loops and Repetitive Computations For More Example Using Loops Example 35 (contd) printing of first row print the first day i= i+1 no i < 7? yes printf("%6d", i) exit no i < =n? i = i+7 printf("\n") printing

More information

Multivariate Regression (Chapter 10)

Multivariate Regression (Chapter 10) Multivariate Regression (Chapter 10) This week we ll cover multivariate regression and maybe a bit of canonical correlation. Today we ll mostly review univariate multivariate regression. With multivariate

More information

SDS developer guide. Develop distributed and parallel applications in Java. Nathanaël Cottin. version

SDS developer guide. Develop distributed and parallel applications in Java. Nathanaël Cottin. version SDS developer guide Develop distributed and parallel applications in Java Nathanaël Cottin sds@ncottin.net http://sds.ncottin.net version 0.0.3 Copyright 2007 - Nathanaël Cottin Permission is granted to

More information

Constructors - Cont. must be distinguished by the number or type of their arguments.

Constructors - Cont. must be distinguished by the number or type of their arguments. Constructors - Cont. 1 Constructors can be overloaded! must be distinguished by the number or type of their arguments. 2 When no constructor is defined, there is a default constructor with no arguments.

More information

Bits. Chapter 1. Information can be learned through observation, experiment, or measurement.

Bits. Chapter 1. Information can be learned through observation, experiment, or measurement. Chapter 1 Bits Information is measured in bits, just as length is measured in meters and time is measured in seconds. Of course knowing the amount of information is not the same as knowing the information

More information

ASYMPTOTIC COMPLEXITY SEARCHING/SORTING

ASYMPTOTIC COMPLEXITY SEARCHING/SORTING Quotes about loops O! Thou hast damnable iteration and art, indeed, able to corrupt a saint. Shakespeare, Henry IV, Pt I, 1 ii Use not vain repetition, as the heathen do. Matthew V, 48 Your if is the only

More information

CS 347 Parallel and Distributed Data Processing

CS 347 Parallel and Distributed Data Processing CS 347 Parallel and Distributed Data Processing Spring 2016 & Clocks, Clocks, and the Ordering of Events in a Distributed System. L. Lamport, Communications of the ACM, 1978 Notes 15: & Clocks CS 347 Notes

More information

Lecture 14: State Tables, Diagrams, Latches, and Flip Flop

Lecture 14: State Tables, Diagrams, Latches, and Flip Flop EE210: Switching Systems Lecture 14: State Tables, Diagrams, Latches, and Flip Flop Prof. YingLi Tian Nov. 6, 2017 Department of Electrical Engineering The City College of New York The City University

More information

Introduction to functions

Introduction to functions Introduction to functions Comp Sci 1570 Introduction to C++ Outline 1 2 Functions A function is a reusable sequence of s designed to do a particular job. In C++, a function is a group of s that is given

More information

What is mechanical energy? How do we use it? Energy Energy

What is mechanical energy? How do we use it? Energy Energy You probably already have some idea what energy is. is easy to recognize. Yet it can be hard to describe. Where do you think you ve seen energy today? How do you think you will use energy tomorrow? Let

More information

Name: Student number:

Name: Student number: UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL 2018 EXAMINATIONS CSC321H1S Duration 3 hours No Aids Allowed Name: Student number: This is a closed-book test. It is marked out of 35 marks. Please

More information

Information and Entropy. Professor Kevin Gold

Information and Entropy. Professor Kevin Gold Information and Entropy Professor Kevin Gold What s Information? Informally, when I communicate a message to you, that s information. Your grade is 100/100 Information can be encoded as a signal. Words

More information

EECS150 - Digital Design Lecture 15 SIFT2 + FSM. Recap and Outline

EECS150 - Digital Design Lecture 15 SIFT2 + FSM. Recap and Outline EECS150 - Digital Design Lecture 15 SIFT2 + FSM Oct. 15, 2013 Prof. Ronald Fearing Electrical Engineering and Computer Sciences University of California, Berkeley (slides courtesy of Prof. John Wawrzynek)

More information

Distributed Systems. Time, Clocks, and Ordering of Events

Distributed Systems. Time, Clocks, and Ordering of Events Distributed Systems Time, Clocks, and Ordering of Events Björn Franke University of Edinburgh 2016/2017 Today Last lecture: Basic Algorithms Today: Time, clocks, NTP Ref: CDK Causality, ordering, logical

More information

Mathematical Induction Part Two

Mathematical Induction Part Two Mathematical Induction Part Two Recap from Last Time Let P be some predicate. The principle of mathematical induction states that if If it starts true and it stays P(0) is true true and k ℕ. (P(k) P(k+1))

More information

Lecture 5, CPA Secure Encryption from PRFs

Lecture 5, CPA Secure Encryption from PRFs CS 4501-6501 Topics in Cryptography 16 Feb 2018 Lecture 5, CPA Secure Encryption from PRFs Lecturer: Mohammad Mahmoody Scribe: J. Fu, D. Anderson, W. Chao, and Y. Yu 1 Review Ralling: CPA Security and

More information

CMPT 365 Multimedia Systems. Lossless Compression

CMPT 365 Multimedia Systems. Lossless Compression CMPT 365 Multimedia Systems Lossless Compression Spring 2017 Edited from slides by Dr. Jiangchuan Liu CMPT365 Multimedia Systems 1 Outline Why compression? Entropy Variable Length Coding Shannon-Fano Coding

More information