Synthesis and Granularity Model-Based Programming and Verification.

Slides:



Advertisements
Similar presentations
Functional Decompositions for Hardware Verification With a few speculations on formal methods for embedded systems Ken McMillan.
Advertisements

Module 6: Process Synchronization
Operating Systems Part III: Process Management (Process Synchronization)
CS 267: Automated Verification Lecture 8: Automata Theoretic Model Checking Instructor: Tevfik Bultan.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Chapter 6 Process Synchronization Bernard Chen Spring 2007.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Concurrent Programming James Adkison 02/28/2008. What is concurrency? “happens-before relation – A happens before B if A and B belong to the same process.
Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores.
Strategies for Individuals Problem-Solving and Teams.
Operating Systems CMPSC 473 Mutual Exclusion Lecture 13: October 12, 2010 Instructor: Bhuvan Urgaonkar.
1 Formal Methods in SE Qaisar Javaid Assistant Professor Lecture 05.
Monitors Chapter 7. The semaphore is a low-level primitive because it is unstructured. If we were to build a large system using semaphores alone, the.
6: Process Synchronization 1 1 PROCESS SYNCHRONIZATION I This is about getting processes to coordinate with each other. How do processes work with resources.
Chapter 6: Process Synchronization. Outline Background Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores Classic Problems.
Silberschatz, Galvin and Gagne ©2007 Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Process Synchronization (Or The “Joys” of Concurrent.
Synchronization April 14, 2000 Instructor Gary Kimura Slides courtesy of Hank Levy.
4/17/2017 Section 3.6 Program Correctness ch3.6.
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Process Synchronization.
University of Pennsylvania 9/28/00CSE 3801 Concurrent Programming (Critical Regions, Monitors, and Threads) CSE 380 Lecture Note 6 Insup Lee.
Adopted from and based on Textbook: Operating System Concepts – 8th Edition, by Silberschatz, Galvin and Gagne Updated and Modified by Dr. Abdullah Basuhail,
Operating Systems CSE 411 CPU Management Oct Lecture 13 Instructor: Bhuvan Urgaonkar.
Monitor  Giving credit where it is due:  The lecture notes are borrowed from Dr. I-Ling Yen at University of Texas at Dallas  I have modified them and.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 8, 2005 Background Concurrent.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
Parallel Programming Models Jihad El-Sana These slides are based on the book: Introduction to Parallel Computing, Blaise Barney, Lawrence Livermore National.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
6.3 Peterson’s Solution The two processes share two variables: Int turn; Boolean flag[2] The variable turn indicates whose turn it is to enter the critical.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Operating Systems CSE 411 CPU Management Oct Lecture 14 Instructor: Bhuvan Urgaonkar.
Chap 6 Synchronization. Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Basic Concepts of Component- Based Software Development (CBSD) Model-Based Programming and Verification.
CIS 842: Specification and Verification of Reactive Systems Lecture INTRO-Examples: Simple BIR-Lite Examples Copyright 2004, Matt Dwyer, John Hatcliff,
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Module 6: Process Synchronization Background The.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 11: Synchronization (Chapter 6, cont)
Open Incremental Model Checking (OIMC) and the Role of Contracts Model-Based Programming and Verification.
Synchronicity Introduction to Operating Systems: Module 5.
Operating Systems CSE 411 CPU Management Dec Lecture Instructor: Bhuvan Urgaonkar.
Copyright 2001, Matt Dwyer, John Hatcliff, and Radu Iosif. The syllabus and all lectures for this course are copyrighted materials and may not be used.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Adders Computer Organization I 1 August 2009 © McQuain, Feng & Ribbens 1-bit Full Adder The expressions for the sum and carry lead to the.
Process Synchronization. Objectives To introduce the critical-section problem, whose solutions can be used to ensure the consistency of shared data To.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 6: Process Synchronization.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
CE Operating Systems Lecture 8 Process Scheduling continued and an introduction to process synchronisation.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 5th Edition Copyright © 2015 John Wiley & Sons, Inc. All rights.
OS Winter’03 Concurrency. OS Winter’03 Bakery algorithm of Lamport  Critical section algorithm for any n>1  Each time a process is requesting an entry.
Chapter 4: Business Process and Functional Modeling, continued
Process Synchronization: Semaphores
Auburn University COMP 3500 Introduction to Operating Systems Synchronization: Part 4 Classical Synchronization Problems.
Concurrent Processes.
Chapter 5: Process Synchronization
Monitors Chapter 7.
Objective of This Course
Semaphore Originally called P() and V() wait (S) { while S <= 0
Process Synchronization
Module 7a: Classic Synchronization
Synchronization Hank Levy 1.
Monitors Chapter 7.
Concurrency: Mutual Exclusion and Process Synchronization
Applying Use Cases (Chapters 25,26)
Synchronization Hank Levy 1.
Applying Use Cases (Chapters 25,26)
CSE 153 Design of Operating Systems Winter 2019
Presentation transcript:

Synthesis and Granularity Model-Based Programming and Verification

Introduction Defining the range of component granularity can be quite difficult because Several factors to be considered: level of abstraction, likelihood of change, complexity of a component, etc. A component too small: the interaction between smaller components requires more time and resources A component too large: provides more complex interfaces, is subject to more frequent changes and makes a system using it less flexible. Essential: to find a balance between the factors of cohesion and coupling.

Sample: Producer – Consumer Problem In the following slides some possible solutions for the Producer – Consumer Problem are described and analyzed from an educational point of view. The examples given illustrate how important it is to make the necessary design decisions on the level of abstraction, e.g.

1 producer – 1 consumer – buffer with capacity 1 (coarser) Specification: I a : 0 ≤ pt ≤ 1 Skeleton of the solution: var pt : integer := 0; var B := item; var a, aa := item; # invariant I a Producer ::do true then od Consumer ::do true then od

1 producer – 1 consumer – buffer with capacity 1 (coarser) Guard conditions: B p = wp(pt := pt + 1, I a )  pt = 0 B c = wp(pt := pt – 1, I a )  pt = 1 Abstract solution (with guards): var pt : integer := 0; var B : item; var a, aa := item; # invariant I a Producer ::do true then Deposit: od Consumer ::do true then Fetch: od

Analysis Producer ::do true then Deposit: ; B := a od Consumer ::do true then Fetch: ; aa := B od

1 producer – 1 consumer – buffer with capacity 1 (finer) Specification: Let pt be the fullness-pointer of the buffer, in p and in c the indicators of the critical sections. Invariant I b : 0 ≤ pt ≤ 1  0 ≤ in p ≤ 1  0 ≤ in c ≤ 1  0 ≤ in p + in c ≤ 1 Skeleton of the solution: var pt : integer := 0; var B, a, aa : item; var in p, in c : boolean := 0, 0 # invariant I b

1 producer – 1 consumer – buffer with capacity 1 (finer) Producer ::do true then Deposit: ; B := a; od Consumer ::do true then Fetch: ; aa := B; od

1 producer – 1 consumer – buffer with capacity 1 (finer) Abstract solution (with guards): # variables just as before Producer ::do true then# invariant I b Deposit: ; B := a; od Consumer ::do true then# invariant I b Fetch: ; aa := B; od

Analysis The producing and consuming processes have (finer structure) more granularity in this case, they express it better that producing and consuming are executed in such a critical section preceded by an explicit prologue and followed by an explicit epilogue. Another advantage of this solution is that it can be easily extended to a system with a buffer sized K > 1, more producers and consumers.

M producers, N consumers and a buffer with capacity K > 1 Specification: Let pt i (the number of items deposited in the buffer), pt o (the number of items fetched from the buffer) be pointers where (pt i – pt o ) is the fullness pointer, in p the number of producers in their critical section and in c the number of consumers in their critical section. Invariant I c : 0 ≤ pt i – pt o ≤ K  0 ≤ in p ≤ 1  0 ≤ in c ≤ 1  pt i ≥ 0  pt o ≥ 0 Skeleton of the solution: var pt i, pt o : integer := 0, 0; var B[1..K] of item; var in p, in c : integer := 0, 0; # invariant I c

M producers, N consumers and a buffer with capacity K > 1 Producer[1..M] ::do true then Deposit: ; ; B[pt i mod K] := a; od Consumer[1..N] ::do true then Fetch: ; ; aa := B[pt o mod K]; od

M producers, N consumers and a buffer with capacity K > 1 Abstract solution (with guards): # variables just as before Producer ::do true then# invariant I c Deposit: ; ; B[pt i mod K] := a; od Consumer ::do true then# invariant I c Fetch: ; 0 then pt o := pt o + 1>; aa := B[pt o mod K]; od

Analysis This is a general solution. Producers have mutual exclusion among them. Consumers also have mutual exclusion among them. However, it is still possible that producing and consuming can be executed concurrently. That is why it is worth to divide the prologue into two atomic instructions. It seems that the finer structure (more granularity) of the system makes it possible to increase concurrency. Note: This solution also works correctly in the case of a buffer with capacity K = 1. The coarser granularity has the advantage of expressing and illustrating specific properties of programs better. This is illustrated by the following example.

A variant of the Producer – Consumer Problem Specification: Invariant I d : 0≤ pt ≤ 2 Skeleton of the solution: var pt : integer := 0; var B[1..2] of item; var a, aa, aa1, aa2 : item; # invariant I d P ::do true then Deposit: od C 1 ::do true then Fetch: od C 2 ::do true then Fetch: od

Abstract solution var pt : integer := 0; var B[1..2] of item; var a, aa, aa1, aa2 := item; # invariant I d P ::do true then od C 1 ::do true then od C 2 ::do true then <await pt = 2 then aa2 := B; pt := pt – 1; aa1 := B; pt := pt – 1> od

Analysis This solution has a very coarse granularity like the first example. It is prohibited to produce and consume concurrently, but it is possible to produce an item and consume the very same item alternately. As a result of this process C 2 is never able to consume 2 items from the buffer. This property is known as starvation problem. However, at this level of abstraction it is possible to solve it by modifying the guard condition of process C 1. C 1 ::do true then od

Analysis of the method used The examples above were created manually by a synthesis method suggested by G. R. Andrews. However, there are tools available nowadays that are able to verify automatically whether a system model is correct for a given specification. It may be more complicated to describe the model of a system in detail, but it is the only option for large and complex systems.