Chapter 6.4: Process Synchronization Part 4. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Module 6: Process Synchronization Lecture.

Slides:



Advertisements
Similar presentations
Chapter 16: Recovery System
Advertisements

1 CSIS 7102 Spring 2004 Lecture 9: Recovery (approaches) Dr. King-Ip Lin.
TRANSACTION PROCESSING SYSTEM ROHIT KHOKHER. TRANSACTION RECOVERY TRANSACTION RECOVERY TRANSACTION STATES SERIALIZABILITY CONFLICT SERIALIZABILITY VIEW.
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.
Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware Semaphores.
Lock-Based Concurrency Control
1 CSIS 7102 Spring 2004 Lecture 8: Recovery (overview) Dr. King-Ip Lin.
Recovery CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
CSCI 3140 Module 8 – Database Recovery Theodore Chiasson Dalhousie University.
Chapter 6 Process Synchronization: Part 2. Problems with Semaphores Correct use of semaphore operations may not be easy: –Suppose semaphore variable called.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Crash Recovery. Review: The ACID properties A A tomicity: All actions in the Xaction happen, or none happen. C C onsistency: If each Xaction is consistent,
Recovery from Crashes. ACID A transaction is atomic -- all or none property. If it executes partly, an invalid state is likely to result. A transaction,
ACID A transaction is atomic -- all or none property. If it executes partly, an invalid state is likely to result. A transaction, may change the DB from.
Quick Review of May 1 material Concurrent Execution and Serializability –inconsistent concurrent schedules –transaction conflicts serializable == conflict.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 6.1: Process Synchronization Part Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Process Synchronization Process Synchronization.
Abhinav Kamra Computer Science, Columbia University 2.1 Operating System Concepts Silberschatz, Galvin and Gagne  2002 Chapter 2: Computer-System Structures.
Chapter 6.3: Process Synchronization Part 3
1 Transaction Management Database recovery Concurrency control.
Chapter 6: Synchronization. 6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Module 6: Synchronization 6.1 Background 6.2 The Critical-Section.
©Silberschatz, Korth and Sudarshan17.1Database System Concepts Chapter 17: Recovery System Failure Classification Storage Structure Recovery and Atomicity.
©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.
Adopted from and based on Textbook: Operating System Concepts – 8th Edition, by Silberschatz, Galvin and Gagne Updated and Modified by Dr. Abdullah Basuhail,
Transaction. A transaction is an event which occurs on the database. Generally a transaction reads a value from the database or writes a value to the.
TRANSACTIONS A sequence of SQL statements to be executed "together“ as a unit: A money transfer transaction: Reasons for Transactions : Concurrency control.
Academic Year 2014 Spring. MODULE CC3005NI: Advanced Database Systems “DATABASE RECOVERY” (PART – 1) Academic Year 2014 Spring.
Distributed DBMSPage © 1998 M. Tamer Özsu & Patrick Valduriez Outline Introduction Background Distributed DBMS Architecture Distributed Database.
Solution to Dining Philosophers. Each philosopher I invokes the operations pickup() and putdown() in the following sequence: dp.pickup(i) EAT dp.putdown(i)
2.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 2: Computer-System Structures Computer System Operation I/O Structure.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Thanks to Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2 Computer-System Structures n Computer System Operation n I/O Structure.
Cosc 4740 Chapter 6, Part 3 Process Synchronization.
Switch off your Mobiles Phones or Change Profile to Silent Mode.
Recovery System By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
PMIT-6102 Advanced Database Systems By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University.
Chapter 6: Process Synchronization. Module 6: Process Synchronization Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware.
Chapter 16 Recovery Yonsei University 1 st Semester, 2015 Sanghyun Park.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 5: Process Synchronization.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Chapter 10 Recovery System. ACID Properties  Atomicity. Either all operations of the transaction are properly reflected in the database or none are.
7c.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Module 7c: Atomicity Atomic Transactions Log-based Recovery Checkpoints Concurrent.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 4 Computer Systems Review.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 2: Computer-System Structures Computer System Architecture and Operation.
Section 06 (a)RDBMS (a) Supplement RDBMS Issues 2 HSQ - DATABASES & SQL And Franchise Colleges By MANSHA NAWAZ.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Chapter 17: Recovery System
Database System Concepts ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 17: Recovery System.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 3.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 6: Process Synchronization.
Database Recovery Zheng (Godric) Gu. Transaction Concept Storage Structure Failure Classification Log-Based Recovery Deferred Database Modification Immediate.
16.1Database System Concepts - 6 th Edition Chapter 16: Recovery System Failure Classification Storage Structure Recovery and Atomicity Log-Based Recovery.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
File Processing : Recovery
Chapter 10 Recover System
Advanced Operating Systems - Fall 2009 Lecture 8 – Wednesday February 4, 2009 Dan C. Marinescu Office: HEC 439 B. Office hours: M,
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Chapter 16: Recovery System
Chapter 10 Transaction Management and Concurrency Control
Lecture 2 Part 2 Process Synchronization
Outline Introduction Background Distributed DBMS Architecture
Module 17: Recovery System
Recovery System.
Chapter 6: Synchronization Tools
CSE 542: Operating Systems
CSE 542: Operating Systems
Presentation transcript:

Chapter 6.4: Process Synchronization Part 4

6.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Module 6: Process Synchronization Lecture 6.1 Background The Critical-Section Problem Peterson’s Solution Synchronization Hardware Lecture 6.2: Semaphores Lecture 6.3 Classic Problems of Synchronization Monitors Synchronization Examples Lecture 6.4 Atomic Transactions

6.3 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Synchronization in Linux We recall that prior to version 2.6, Linux was a non-preemptive kernel. Newer versions of the Linux kernel are preemptive. This means a task can be preempted when running in kernel mode. Now, we know that the Linux kernel uses spinlocks and semaphores for locking in the kernel. Recall: Spinlocks – a type of semaphore that causes continual looping executing a busy waiting execution.  It may be costly because the CPU could be busy doing other tasks.  Might be okay, however, in that there is no context switching involved and when the locks are expected to be held for only a very short time, spinlocks may be the way to go.  Often employed on multiprocessor systems because one thread can wait (spin) on one processor while another process executes its critical section on another processor. Semaphores – merely an integer variable itself (usually an integer) that can be accessed controlled only via two atomic operations: wait() and signal().

6.4 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Synchronization in Linux – more As we are aware, in symmetric multiprocessors (SMP), spinlocks will work well if critical section execution is quick. For single processor machines, the mechanism used is to simply enable / disable kernel pre-emption. In summary: in single processors, we disable / enable preemption, while in multiple processor machines, we use spinlocks (acquire and release the spin lock). Now, how does Linux implement the preemption process? Linux employs two system calls: preempt_disable() and preempt_enable().

6.5 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Synchronization in Linux – more Pre-empting the kernel is not always a simple task; at times it may not be safe.  There may be a process executing in kernel mode currently holding lock(s). So, do we really want to preempt such processes??? To address this, each task in the system has what is called a ‘thread-info’ structure that contains an integer counter, preempt_count. This counter indicates the number of locks held by the task. Any time a kernel mode task is holding one or more locks, (lock > 0), then preempting cannot be done.. So only when this count becomes zero (that is, the executing task releases all locks), then a kernel process can be interrupted via the system calls. As we recall, spinlocks and kernel preemption/non-preemption are acceptable approaches when a lock is held for a short time. If a lock must be held for longer periods, a semaphore is used and typically a process blocks.

6.6 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts 6.9 Atomic Transactions Goal is to ensure critical sections are executed atomically by using mutual exclusion mechanisms.  Motivation: execute critical section totally or not at all. Long time focus in data base systems where one is not allowed to read, say, financial data, when the file / database is undergoing updating by another process. Much research has taken place in the database arena. Thinking: apply this research to operating systems too. These are the ideas behind atomic transactions. The transaction must execution to completion.

6.7 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts The System Model Transaction – a series of instructions that must run from beginning to end (atomic execution) – considered a ‘single logical function.’ Here, we are reading and writing – terminated by ‘commit’ or ‘abort.’ Commit implies that transaction has completed a successful execution. Abort implies that the transaction terminated due to logical error or system failure. Now, an aborted transaction may have updated data and this data might not be in the correct ‘state’ when the transaction terminated abnormally. Thus, we must undertake some kind of roll back or restore to get the data back to its previous stable / reliable state.

6.8 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts The System Model – more; Devices So we must talk about device properties used to store data that might be involved in some kind of rollback. Volatile Storage – usually does not survive a system crash (central memory and cache) Nonvolatile Storage – data usually survives crashes (disks, magnetic tapes, …) Stable Storage - Information never lost. Here we  replicate information in ‘non-volatile storage caches’ (generally disk) with independent failure models and to  update the information in a controlled manner. (later chapters)

6.9 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts The System Model – more; the Log We also have a Log. Before a write() is ultimately executed, all ‘log’ info must be written to stable storage. Clearly, this incurs a very serious performance penalty!! Additional ‘Writes’ plus additional storage are needed for the log, etc. But where vitally important, such as in secure environments, financial environments, and more, this performance penalty is worth the price. In general terms, by using the log, the system is able to recover from a failure and recover from a partial update. Two algorithms are needed: An undo() – restores values of data prior to Transaction A redo() – sets values of data to new values. Both old values and new values must have been loaded into the log for these two algorithms to be successful. Naturally, failure can occur during recovery. So this process must be idempotent (yield same results if executed repeatedly).

6.10 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Checkpoints in Logs Here again, consider what we have: we have a log and the log is used to determine which transactions need to be undone and/or redone. It would first appear that we might conceivably have to go through the entire log to determine a set of transactions that need reconsideration. Major Disadvantages: Search process takes time. Recovery takes lots of time We can save time by undertaking ‘checkpoints.’ Essentially, in addition to the write-ahead logging, the system performs periodic checkpoints. Process is: Output all log records currently residing in volatile storage (PM) onto stable memory Output all modified data residing in volatile storage to the stable storage Output a log record onto stable storage.

6.11 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Checkpoints The process of establishing checkpoints in the log helps to shorten the recovery time, and it makes sense If transaction T1 is committed prior to the checkpoint, T1 commit record is in log. Here, any modifications made by T1 must have already been written to stable storage either prior to the checkpoint or as part of the checkpoint itself. In recovery, then, there is no need for a redo on the transaction. So, a recovery routine now only examines the log to determine the most recent transaction that started into execution before the most recent checkpoint took place. Does so by searching log backward to find first record and then finding the that follows it. So the redo and undo only need to be accommodated on this transaction and any others that started after.

6.12 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Log-Based Recovery To enable atomicity: Record on stable storage information describing all modifications made by transaction to data it has accessed. This method is referred to as write-ahead logging. (this is not new) System maintains a data structure called a log. Log itself consists of records describing transaction particulars:  Transaction name – unique name of trans that performed the write operation  Data item name – unique name of the data item written  Old value: value prior to the write  New value: value that data item should have after the write. Process: Prior to transaction execution, original record written to log After every ‘write’ a new record is written. Upon completion, a is written to the log.

6.13 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Summarizing This chapter was all about working with sequential processes that must share data. Of course, mutual exclusion and synchronization must be ensured. Critical Sections can be accessed by only one process at a time. Different approaches were presented to deal with this phenomenon. Main disadvantage of user-coded solutions is they usually require busy waiting. Semaphores overcome this and can be used with various schemes especially if there is hardware support for atomic instructions. Classic Problems: There is a large class of concurrency-related problems addressed by the classic bounded-buffer problem, the readers-writers problem, and the dining-philosopher problem. Monitors provide a synchronization mechanism by using an abstract data type (ADT). Condition variables provide a method by which a monitor procedure can provide additional constraints and block a process’ execution until the process is signaled to continue. We looked at Linux and discussed logs with checkpoints for recovery.

End of Chapter 6 Part 3