Solution to Dining Philosophers. Each philosopher I invokes the operations pickup() and putdown() in the following sequence: dp.pickup(i) EAT dp.putdown(i)

Slides:



Advertisements
Similar presentations
Chapter 6: Process Synchronization
Advertisements

Chapter 6 Process Synchronization: Part 2. Problems with Semaphores Correct use of semaphore operations may not be easy: –Suppose semaphore variable called.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 8, 2005 Module 6: Process Synchronization.
Chapter 6.4: Process Synchronization Part Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Module 6: Process Synchronization Lecture.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Silberschatz, Galvin and Gagne ©2007 Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Chapter 6: Process Synchronization.
Chapter 6: Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware.
Critical Regions § 7.6 Although semaphores provide a convenient and effective mechanism for process synchronization, their incorrect use can still result.
©Silberschatz, Korth and Sudarshan17.1Database System Concepts 3 rd Edition Chapter 17: Recovery System Failure Classification Storage Structure Recovery.
6: Process Synchonization II 1 PROCESS SYNCHRONIZATION II THE BOUNDED BUFFER ( PRODUCER / CONSUMER ) PROBLEM: This is the same producer / consumer problem.
Modified from Silberschatz, Galvin and Gagne & Stallings Lecture 12 Chapter 6: Process Synchronization (cont)
Massively Distributed Database Systems - Transaction management Spring 2014 Ki-Joune Li Pusan National University.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Cosc 4740 Chapter 6, Part 3 Process Synchronization.
6.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Module 6: Process Synchronization.
Chapter 15 Concurrency Control Yonsei University 1 st Semester, 2015 Sanghyun Park.
Chapter 6: Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware.
TRANSACTION MANAGEMENT R.SARAVANAKUAMR. S.NAVEEN..
Concurrency Control in Database Operating Systems.
UNIT III: Concurrency Process SynchronizationSynchronization The Critical-Section problemCritical-Section problem Peterson’s Solution Synchronization HardwareHardware.
Operating System Concepts 7th Edition Abraham SilBerschatz Peter Baer Galvin Greg Gagne Prerequisite: CSE212.
Chapter 6: Process Synchronization Adapted to COP4610 by Robert van Engelen.
Chapter 6: Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Module 6: Synchronization Background The Critical-Section.
Chapter 15: Transactions Loc Hoang CS 157B. Definition n A transaction is a discrete unit of work that must be completely processed or not processed at.
7c.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Module 7c: Atomicity Atomic Transactions Log-based Recovery Checkpoints Concurrent.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Module 6: Process Synchronization Background The.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 8, 2005 Module 6: Process Synchronization.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 8, 2005 Outline n Background.
6.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Module 6: Synchronization.
Process Synchronization Monitors Simulation of Monitors Checkpoint and Recovery Monitors Simulation of Monitors Checkpoint and Recovery Topics:
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 8, 2005 Module 6: Process Synchronization.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Module 6: Process Synchronization Background The.
Chapter 6: Synchronization. 6.2Operating System Principles Module 6: Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 8, 2005 Module 6: Process Synchronization.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 6 Operating Systems.
Chapter 6: Process Synchronization. 6.2 Chapter 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 8, 2005 Module 6: Process Synchronization.
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 8, 2005 Module 6: Process Synchronization.
Chapter 6: Process Synchronization. 6.2CSCI 380 – Operating Systems Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s.
Transaction Management Transparencies. ©Pearson Education 2009 Chapter 14 - Objectives Function and importance of transactions. Properties of transactions.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Timestamp-based Concurrency Control
Chapter 6: Process Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Module 6: Process Synchronization.
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, Chapter 6: Process Synchronization.
Module 6: Process Synchronization
Chapter 6: Process Synchronization
Chapter 6: Process Synchronization
Chapter 10 Recover System
Part- A Transaction Management
Advanced Operating Systems - Fall 2009 Lecture 8 – Wednesday February 4, 2009 Dan C. Marinescu Office: HEC 439 B. Office hours: M,
Chapter 6: Process Synchronization
Chapter 6: Process Synchronization
Chapter 6: Process Synchronization
Chapter 6: Process Synchronization
Chapter 6: Process Synchronization
Chapter 6: Process Synchronization
File Processing : Transaction Management
Chapter 6: Process Synchronization
Chapter 6: Process Synchronization
Chapter 6: Process Synchronization
Chapter 6: Process Synchronization
Module 6: Process Synchronization
Chapter 6: Process Synchronization
Chapter 6: Synchronization
Process Synchronization
Chapter 6: Process Synchronization
CSE 542: Operating Systems
Chapter 6: Process Synchronization
Chapter 6: Process Synchronization
Presentation transcript:

Solution to Dining Philosophers

Each philosopher I invokes the operations pickup() and putdown() in the following sequence: dp.pickup(i) EAT dp.putdown(i)

6.8 Synchronization Examples Solaris Windows XP Linux

Synchronization in Solaris It provides adaptive mutexes, condition variables, semaphores, reader-writer locks and turnstiles

Adaptive Mutexes Adaptive mutexes protects access to every critical data item If a lock is held by a thread that is currently running on another CPU, the thread spins while waiting for the lock, because the thread holding the lock is likely to finish soon If the thread holding the lock is not currently in run state, the thread blocks, going to sleep until it is awaken by the release of the lock (kernel preemption)

Synchronization in Solaris Reader-Writer locks: multiple threads can read data concurrently, where semaphores always serialize access to data Turnstile: a queue structure containing threads blocked on a lock.

Synchronization in Windows XP Uses interrupt masks to protect access to global resources on uniprocessor systems Uses spin locks on multiprocessor systems

Synchronization in Linux Linux uses an interesting approach to disable and enable kernel preemption by two system calls: preempt disable() preempt enable()

6.9 Atomic Transactions The mutual exclusion of critical sections ensures that the critical sections are executed atomically. That is, if two critical sections are executed concurrently, the result is equivalent to their sequential execution. An example is funds transfer, where one account is debited and another is credited

6.9 Atomic Transactions Consistency of data is a concern often associated with database system Recently, there has been an upsurge of system interest in using database- system techniques in OS

6.9 Atomic Transactions A collection of instructions that performs a single logical function is called a transaction If a terminated transaction has completed its execution successfully, it is committed, otherwise, it is aborted

Types of storage media Volatile storage –information stored here does not survive system crashes Example: main memory, cache Nonvolatile storage –Information usually survives crashes Example: disk Stable storage –Information never lost Example: magnetic tape

6.9 Atomic Transactions Our goal is to ensure transaction atomicity in an environment where failures result in the loss of information on volatile storage

Log-Based Recovery Algorithm Most common is write-ahead logging Each log contains Transaction name Data item name Old value New value

Log-Based Recovery Algorithm written to log when transaction Ti starts During its execution, any write operation by Ti is preceded by the writing of the appropriate new record to the log written when Ti commits

Log-Based Recovery Algorithm Log entry must reach stable storage before operation on data occurs Performance penalty: 1. two physical writes are required 2. extra storage is required

Log-Based Recovery Algorithm Using the log, system can handle any volatile memory errors Undo(Ti) restores value of all data updated by Ti Redo(Ti) sets values of all data in transaction Tito new values

Log-Based Recovery Algorithm If system fails, restore state of all updated data via log If log contains without, undo(Ti) If log contains and, redo(Ti)

Checkpoints When a system failure occurs, we must consult the log to determine those transactions that need to be redone and those need to be undone The search is time consuming

Checkpoints To reduce the overhead, we introduce the concept of checkpoints During execution, the system maintains the write-ahead log. In addition, the system periodically performs checkpoints that require the following sequence of actions to take place: 1. Output all log records currently in volatile storage to stable storage 2.Output all modified data from volatile to stable storage 3.Output a log record to the log on stable storage

Concurrent Transactions We have been considering an environment where only one transaction can be executing at a time. We now turn to the case where multiple transactions are active simultaneously Serializability: since each transaction is atomic, the concurrent execution of transactions must be equivalent to the case where these transactions are executed serially.

Concurrency-control algorithms Concurrency-control algorithms provide serializability

Schedule 1: T0 then T1

Concurrency-control algorithms Non-serial schedule allows overlapped execute (Resulting execution not necessarily incorrect) Conflict: Consider schedule S, we say that operations Oi, Oj conflict if they access same data item, with at least one of them is write operation

Schedule 2: Concurrent Serializable Schedule

Concurrency-control algorithms If Oi, Oj consecutive and operations of different transactions & Oi and Oj don’t conflict, then S’ with swapped order Oj Oi equivalent to S Example: Swap read(B) of T0 with write(A) of T1 Swap read(B) of T0 with read(A) of T1 Swap write(B) of T0 with write(A) of T1 Swap write(B) of T0 with read(A) of T1

Concurrency-control algorithms If S can become S’ via swapping non- conflicting operations then S is conflict serializable

Timestamp Timestamp-based Protocols Select order among transactions in advance – timestamp-ordering Transaction Ti associated with timestamp TS(Ti) before Tistarts TS(Ti) < TS(Tj) if Ti entered system before Tj TS can be generated from system clock or as logical counter incremented at each entry of transaction

Timestamp Timestamp- based Protocols Timestamps determine serializability order If TS(Ti) < TS(Tj), system must ensure produced schedule equivalent to serial schedule where Ti appears before Tj

Timestamp Timestamp- based Protocols Data item Q gets two timestamps W-timestamp(Q) –largest timestamp of any transaction that executed write(Q) successfully R-timestamp(Q) –largest timestamp of successful read(Q) Updated whenever read(Q) or write(Q) executed

Timestamp Timestamp- based Protocols Suppose Ti executes read(Q) If TS(Ti) < W-timestamp(Q), Ti needs to read value of Q that was already overwritten Read operation rejected and Ti rolled back If TS(Ti) ≥W-timestamp(Q) Read executed, R-timestamp(Q) set to max(R-timestamp(Q), TS(Ti))

Timestamp Timestamp- based Protocols Suppose Ti executes write(Q) If TS(Ti) < R-timestamp(Q), value Q produced by Ti was needed previously and Ti assumed it would never be produced Write operation rejected, Ti rolled back If TS(Ti) < W-tiimestamp(Q), Ti attempting to write obsolete value of Q Write operation rejected and Ti rolled back Otherwise, write executed

Timestamp Timestamp- based Protocols Any rolled back transaction Ti is assigned new timestamp and restarted Algorithm ensures conflict serializability and freedom from deadlock