Copyright © 1997 - 2011 - Curt Hill Concurrent Execution An Overview for Database.

Slides:



Advertisements
Similar presentations
Symmetric Multiprocessors: Synchronization and Sequential Consistency.
Advertisements

1 Interprocess Communication 1. Ways of passing information 2. Guarded critical activities (e.g. updating shared data) 3. Proper sequencing in case of.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
CSEN5322 Quiz-5.
Chapter 6: Process Synchronization
Data and Database Administration Chapter 12. Outline What is Concurrency Control? Background Serializability  Locking mechanisms.
Transaction Management and Concurrency Control
Review: Process Management Objective: –Enable fair multi-user, multiprocess computing on limited physical resources –Security and efficiency Process: running.
Concurrent Processes Lecture 5. Introduction Modern operating systems can handle more than one process at a time System scheduler manages processes and.
Concurrency: Deadlock and Starvation Chapter 6. Revision Describe three necessary conditions for deadlock Which condition is the result of the three necessary.
Transaction Management and Concurrency Control
OS Spring 2004 Concurrency: Principles of Deadlock Operating Systems Spring 2004.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
OS Fall’02 Concurrency: Principles of Deadlock Operating Systems Fall 2002.
1 Concurrency: Deadlock and Starvation Chapter 6.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Transaction Management and Concurrency Control
Operating Systems CSE 411 CPU Management Oct Lecture 13 Instructor: Bhuvan Urgaonkar.
1 Concurrency: Deadlock and Starvation Chapter 6.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic,
Object Oriented Analysis & Design SDL Threads. Contents 2  Processes  Thread Concepts  Creating threads  Critical sections  Synchronizing threads.
Solution to Dining Philosophers. Each philosopher I invokes the operations pickup() and putdown() in the following sequence: dp.pickup(i) EAT dp.putdown(i)
Cosc 4740 Chapter 6, Part 3 Process Synchronization.
Concurrency, Mutual Exclusion and Synchronization.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Introduction to Concurrency.
4061 Session 23 (4/10). Today Reader/Writer Locks and Semaphores Lock Files.
Critical Problem Revisit. Critical Sections Mutual exclusion Only one process can be in the critical section at a time Without mutual exclusion, results.
Copyright © 1997 – 2014 Curt Hill Concurrent Execution of Programs An Overview.
1 Announcements The fixing the bug part of Lab 4’s assignment 2 is now considered extra credit. Comments for the code should be on the parts you wrote.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Mutual Exclusion.
The Relational Model1 Transaction Processing Units of Work.
Chapter 7 -1 CHAPTER 7 PROCESS SYNCHRONIZATION CGS Operating System Concepts UCF, Spring 2004.
CY2003 Computer Systems Lecture 04 Interprocess Communication.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Module 6: Process Synchronization Background The.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Copyright © Curt Hill Parallelism in Processors Several Approaches.
HXY Debugging Made by Contents 目录 History of Java MT Sequential & Parallel Different types of bugs Debugging skills.
Operating Systems CSE 411 CPU Management Dec Lecture Instructor: Bhuvan Urgaonkar.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
9 1 Chapter 9_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
10 1 Chapter 10_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
CS4315A. Berrached:CMS:UHD1 Process Synchronization Chapter 8.
1 Processes and Threads Part II Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
SMP Basics KeyStone Training Multicore Applications Literature Number: SPRPxxx 1.
Copyright © Curt Hill More on Operating Systems Continuation of Introduction.
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Chapter 5: Process Synchronization
G.Anuradha Reference: William Stallings
Transaction Management and Concurrency Control
Advanced Operating Systems - Fall 2009 Lecture 8 – Wednesday February 4, 2009 Dan C. Marinescu Office: HEC 439 B. Office hours: M,
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Lecture 2 Part 2 Process Synchronization
Chapter 7: Synchronization Examples
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Concurrency: Mutual Exclusion and Process Synchronization
- When you approach operating system concepts there might be several confusing terms that may look similar but in fact refer to different concepts:  multiprogramming, multiprocessing, multitasking,
CS333 Intro to Operating Systems
Operating System Overview
CSE 542: Operating Systems
CSE 542: Operating Systems
Chapter 3: Process Management
Presentation transcript:

Copyright © Curt Hill Concurrent Execution An Overview for Database

Copyright © Curt Hill MultiTasking Multitasking is the apparent execution of programs in parallel This supports parallel execution usually under one or more of these names –Tasks –Processes –Threads This can be accomplished with a single processor or with several processors

Copyright © Curt Hill Definitions Process –An executable program to the OS –Sole possession of code and variable memory –Must communicate through the OS Thread –Independent execution within a process –Share code and variables within a process These work in Win32 and UNIX Tasks can be either

Copyright © Curt Hill Single Processor UniProcessing Single CPU, but apparent multiple tasks Permissive –Any system call allows the current task to be suspended and another started Preemptive –A task is suspended when it makes a system call that could require waiting –A time slice occurs

Copyright © Curt Hill Multiple Processors MultiProcessing Real multiprocessing involves multiple CPUs Multiple CPUs can be executing different jobs They may also be in the same job, if it allows A DBMS is usually multi-threaded

Copyright © Curt Hill Off to the Races Most programming languages are Sequential There are a number of kinds of errors that can occur when there are two simultaneously executing tasks that share anything When different results may be obtained by the same code and data because of time dependencies, this is called a race

Granularity At the program level we are concerned with instruction granularity –On uniprocessors individual instructions are usually atomic –No guarantees of any sort with multiprocessors At the database level we are concerned with transaction granularity –Since a transaction generally involves multiple database accesses and hundreds of machine instructions even fewer guarantees Copyright © Curt Hill

Race Example Consider two transactions Transaction A has –Read row x of table y –Add 2 to field z –Write row x of table y Transaction B has –Read row x of table y –Add 5 to field z –Write row x of table y

Copyright © Curt Hill Racing Form Read x of y Add 2 to z Write x of y Read x of y Add 5 to z Write x of y There are three possible outcomes. It all depends on where a time slice occurs.

Copyright © Curt Hill Race Results If transactions are serialized z will have 7 added to it If A starts and is interrupted, then the add of two is kept and the add of five is lost If B starts first and is interrupted, then the add of five is kept and the add of two is lost Without precautions we could end with a add of 2, 5 or 7

Query Race This gets complicated when multiple updates must occur as a unit Consider the airline reservation problem I want to book a flight from: Fargo to Minneapolis Minneapolis to Atlanta Atlanta to Pensacola Each leg reservation is competing with many others and I must have them as a unit Copyright © Curt Hill

How to solve? At the machine instruction level there are several techniques –Critical sections –Mutexes –Semaphores All of these involve some kind of lock Locks come in two flavors: –Shared –Exclusive Copyright © Curt Hill

Lock Types An exclusive lock only allows one thread to have control –Usually used for write or update Any others that attempt are forced to wait A shared lock is usually used for reading Any number of items can share but one exclusive lock prevents all shared or is forced to wait until all shared locks are released Copyright © Curt Hill

Waiting If a lock prohibits entry the task must wait Two kinds of wait: –Busy wait - spin in a loop –Idle wait - suspended until later This wait time keeps a multi CPU system from reaching its true potential, especially while in the dispatcher

Copyright © Curt Hill Locked Solution Lock y Read x of y Add 2 to z Write x of y Unlock y Lock y Read x of y Add 5 to z Write x of y Unlock y Always update z to 7 larger

Lock Granularity In the above example an exclusive lock was applied to the entire table Databases have considerable variance as to what may be lockable: Tables Pages Records Fields The finer the granularity the less conflicts there will be –Thus better performance –However, much more bookkeeping Copyright © Curt Hill

Wait Problems A critical section guarded by a semaphore is a special case of resource allocation In order for a task to complete it has to ask for and receive a resource –If it cannot, it is forced to wait This however allows for other problems

Copyright © Curt Hill Deadlock Situation where tasks cannot get the resources they need Task A has resource 1 and is waiting for resource 2 Task B has resource 2 and is waiting for resource 1 Both are waiting for a situation that cannot be resolved

Copyright © Curt Hill The Dining Philosophers Problem h

Copyright © Curt Hill The Dining Philosophers Problem There is a round table with five philosophers, five plates of spaghetti and five forks A philosopher always picks up the right fork, then the left, then eats If all five reach out their right hand at the same time all the forks are gone then there is a deadlock

Copyright © Curt Hill Traffic Deadlock

Traffic Deadlock Again Car A –Holds resource 1, which is street in front of West street –Wants resource 2, which is street in front of East street Car B –Holds resource 2, which is street in front of East street –Wants resource 1, which is street in front of West street In order to turn, each needs both It can get much more complicated Copyright © Curt Hill

Deadlock Is it a programmer problem or a DBMS problem? Both.

Copyright © Curt Hill Avoiding Deadlock A DBMS should be able to detect a deadlock Usual solution is to abort transactions until something can proceed Ability to reclaim a resource also required Programmer should avoid situations that might lead to it: Do not wait for a resource while holding a resource