Concurrency Specification

Slides:



Advertisements
Similar presentations
1 Interprocess Communication 1. Ways of passing information 2. Guarded critical activities (e.g. updating shared data) 3. Proper sequencing in case of.
Advertisements

Operating Systems: Monitors 1 Monitors (C.A.R. Hoare) higher level construct than semaphores a package of grouped procedures, variables and data i.e. object.
Operating Systems Mehdi Naghavi Winter 1385.
Operating Systems Lecture Notes Deadlocks Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
Chapter 6: Process Synchronization
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
CS 5704 Fall 00 1 Monitors in Java Model and Examples.
1 Concurrency: Mutual Exclusion and Synchronization Chapter 5.
1 Concurrency Specification. 2 Outline 4 Issues in concurrent systems 4 Programming language support for concurrency 4 Concurrency analysis - A specification.
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.
Atomicity in Multi-Threaded Programs Prachi Tiwari University of California, Santa Cruz CMPS 203 Programming Languages, Fall 2004.
02/19/2010CSCI 315 Operating Systems Design1 Process Synchronization Notice: The slides for this lecture have been largely based on those accompanying.
Chapter 6: Process Synchronization. Outline Background Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores Classic Problems.
Concurrency: Deadlock and Starvation Chapter 6. Revision Describe three necessary conditions for deadlock Which condition is the result of the three necessary.
Concurrency CS 510: Programming Languages David Walker.
Process Synchronization
Chapter 11: Distributed Processing Parallel programming Principles of parallel programming languages Concurrent execution –Programming constructs –Guarded.
02/23/2004CSCI 315 Operating Systems Design1 Process Synchronization Notice: The slides for this lecture have been largely based on those accompanying.
02/17/2010CSCI 315 Operating Systems Design1 Process Synchronization Notice: The slides for this lecture have been largely based on those accompanying.
02/19/2007CSCI 315 Operating Systems Design1 Process Synchronization Notice: The slides for this lecture have been largely based on those accompanying.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
ABSTRACT The real world is concurrent. Several things may happen at the same time. Computer systems must increasingly contend with concurrent applications.
1 Concurrency Architecture Types Tasks Synchronization –Semaphores –Monitors –Message Passing Concurrency in Ada Java Threads.
Using a simple Rendez-Vous mechanism in Java
1 Interprocess Communication (IPC) - Outline Problem: Race condition Solution: Mutual exclusion –Disabling interrupts; –Lock variables; –Strict alternation.
Debugging Threaded Applications By Andrew Binstock CMPS Parallel.
13-1 Chapter 13 Concurrency Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads C# Threads.
Deadlock cs550 Operating Systems David Monismith.
Comunication&Synchronization threads 1 Programación Concurrente Benemérita Universidad Autónoma de Puebla Facultad de Ciencias de la Computación Comunicación.
Software Systems Verification and Validation Laboratory Assignment 4 Model checking Assignment date: Lab 4 Delivery date: Lab 4, 5.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
Semaphores Chapter 6. Semaphores are a simple, but successful and widely used, construct.
Operating Systems Unit 4: – Dining Philosophers – Deadlock – Indefinite postponement Operating Systems.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee.
Deadlock and Starvation
Victor Khomenko Newcastle University
Multithreading / Concurrency
Semaphore Synchronization tool that provides more sophisticated ways (than Mutex locks) for process to synchronize their activities. Semaphore S – integer.
Chapter 5: Process Synchronization – Part 3
Process Synchronization
Chapter 5: Process Synchronization
Classical Synchronization Problems
Deadlock and Starvation
Chapter 6: Process Synchronization
Definitions Concurrent program – Program that executes multiple instructions at the same time. Process – An executing program (the running JVM for Java.
Chapter 6: Process Synchronization
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Concurrency: Mutual Exclusion and Synchronization
Chapter 5: Process Synchronization (Con’t)
Monitors Chapter 7.
Atomicity in Multithreaded Software
Lecture 25 Syed Mansoor Sarwar
Midterm review: closed book multiple choice chapters 1 to 9
Process Synchronization
Module 7a: Classic Synchronization
Concurrency in Java Last Updated: Fall 2010 Paul Ammann SWE 619.
Lecture 2 Part 2 Process Synchronization
Semaphores Chapter 6.
Monitors Chapter 7.
Concurrency: Mutual Exclusion and Process Synchronization
Monitors Chapter 7.
CS561 Computer Architecture Hye Yeon Kim
EECE.4810/EECE.5730 Operating Systems
Software Engineering and Architecture
CSE 542: Operating Systems
CSE 542: Operating Systems
Synchronization and liveness
Presentation transcript:

Concurrency Specification Aliasgar Rampurwala Aditya Garg 11/9/2018

Outline Issues in concurrent systems Programming language support for concurrency Concurrency analysis - A specification based approach Concurrency and other formal methods Deadlock Checker Concurrency and architectures 11/9/2018

Concurrency Coexistence Sharing of resources Issues Solution Results Asynchronicity Non-determinism Solution Locks Results Deadlock and starvation 11/9/2018

Concurrency in various disciplines Databases Transaction serializability Operating Systems Multithreading Electronic circuits Flip flops Real life Gas station example 11/9/2018

Concurrency in architecture implementations 11/9/2018

PL support for concurrency - 1 Fork and join constructs Queue construct and the signal operation Concurrent Pascal The Java synchronized keyword 11/9/2018

PL support for concurrency - 2 Communicating sequential processes [CSP] Producer command : consumer!m Consumer command : producer?n Guarded commands <guard> —› <command-list> guard : list of declarations, boolean expressions or an input command alternative guarded command [ G1 —› C1 ƀ G2 —› C2 ƀ …. ƀ Gn —› Cn] 11/9/2018

From Specification to Implementation - 1 11/9/2018

From Specification to Implementation - 2 Specification Phase Implementation Phase Easy to verify safety Difficult to verify and liveness safety and liveness State spaces small State spaces and manageable large and unmanageable; testing difficult Cost of correcting Cost of correcting flaws is low flaws is high 11/9/2018

Specification-based model - 1 Synchronizer construct set of variables defining the state of shared resources set of operations on these variables (with pre/post conditions) set of invariants safety conditions liveness conditions 11/9/2018

Specification-based model - 2 Process construct independent thread of execution multiple processes coexist control allocation/deallocation of synchronizer controlled resources Example: Web server : synchronizer Web browser : process 11/9/2018

Gas-station model 11/9/2018

Gas-station model - Program spec 11/9/2018

Gas station model - RSTG 11/9/2018

Gas station model - Event expressions Two customers trying to buy gas concurrently 11/9/2018

Gas station model - Reachability graph Identifies the states that can be reached by executing enabled operations in processes and synchronizers Constructed from event expressions and RSTG Nodes represent states of RSTG Edges represent operations from event expressions A deadlock occurs if the graph contains terminal nodes 11/9/2018

Tool support for concurrency analysis INCA(Inequality Necessary Condition Analysis) checks properties of an architectural specification (ex. Mutual exclusion) provides example executions that violate those properties verifies that a modification removes the faults 11/9/2018

Detecting a race condition Customer1 pays before Customer2 but Customer2 takes up the hose before Customer1 thus getting the amount of gas purchased by Customer1 11/9/2018

The INCA query 11/9/2018

INCA results INCA generates a system of inequalities based on the violation of properties specified by the query a consistent inequality implies such a situation is possible an inconsistent inequality implies such a situation is impossible 11/9/2018

Features common with other formal methods RSTG Pre and post conditions State invariants 11/9/2018

Unique Features - 1 Operation execution phases Request phase Enabled phase Service phase only one operation invocation can be in the service phase. Terminate phase Example: Fair scheduler: []<>enabled(o) -> <>service(o) 11/9/2018

Unique Features - 2 Separation of control resources from state variables Event expressions help “walk through” the concurrency aspect Semantics of allocation and deallocation helpful in detecting deadlocks 11/9/2018

Deadlock Checker Performs checks on parallel programs written in CSP in order to prove freedom from deadlock Takes in a network file(.net) that has been compiled from a CSP source file using a tool such as FDR More information : http://users.ox.ac.uk/~jeremy/Deadlock/ 11/9/2018

The Dining Philosophers Problem 5 philosophers and 5 chopsticks All philosophers keep thinking When a philosopher feels hungry, he picks up the chopsticks closest to him, eats rice and keeps the chopsticks back Deadlock : When all philosophers grab their left chopstick simultaneously 11/9/2018

The Dining Philosophers Problem 11/9/2018

Architectures and concurrency Component types: Synchronizer Process units Connector Synchronization connector 11/9/2018

Synchronization Connector 11/9/2018

A simple Binary Semaphore Connector in Java package architecture.connector; import java.lang; import architecture.framework; public class SyncConnector extends Connector { private boolean available; public SyncConnector() { available = true; } public void handle(Request r) { String messageName = r.getName(); if(messageName.equals("AccessResource")) { if(!available) { wait(); if(available) { available = false; super.handle(r); 11/9/2018

A simple Binary Semaphore Connector in Java (contd) public void handle(Notification n) { String messageName = n.getName(); if(messageName.equals("ReleaseResource")) { available = true; notifyAll(); } 11/9/2018

Conclusions and Discussion Analysis of concurrent systems early in the development process reduces complexity and cost of correcting errors A formal analysis will help detect deadlocks and starvation and also in direct code generation Concurrency in software architectures can be represented in terms of CSPs 11/9/2018