...COS 318: Operating Systems Deadlocks Today’s Topics Conditions for a deadlock Strategies to deal with deadlocks Announcement Last year’s midterm and solution is on the course web page 2 Definitions Use processes and threads interchangeably Resources Use a resource Request, Use, Release Starvation Preemptable: CPU (can be taken away) Non-preemptable: Disk, files, mutex, ... (can’t be taken away) Processes wait indefinitely Deadlocks A set of processes have a deadlock if each process is waiting for an event that only another process in the set can cause 3 Resource Allocation Graph Process A is holding resource R A R Process B requests resource S B S A cycle in resource allocation graph ⇒ deadlock If A requests for S while holding R, and B requests for R while holding S, then A S R B How do you deal with multiple instances of a resource? 4 An Example A utility program A Resources Copy a file from tape to disk Print the file to printer Tape Disk Printer Tape A deadlock A holds tape and disk, then requests for a printer B holds printer, then requests for tape and disk B 5 Conditions for Deadlock Mutual exclusion condition Hold and Wait Resources cannot be taken away Circular chain of requests Processes holding resources can request new resources No preemption Each resource is assigned to exactly one process One...
Words: 1230 - Pages: 5
...Deadlock Detector and Solver Abstract Deadlock is one of the most serious and complex problems concerning the reliability of concurrent Java Programs. This paper presents Deadlock Detector and Solver which detects and resolves circular deadlocks of a java program. An agent written in C++ runs parallel to Java Program and monitors the Java Virtual Machine for deadlocks. If the deadlock is detected, the solver agent is used to resolve the deadlock . Introduction The onset of multicore processors forces the programmers to use multiple threads in order to take advantage of hardware parallelism. Java is one of the first languages to make multithreading available to developers. Along with advantages of concurrent systems and multithreading, there are some challenges involved. Java has inter-process communication model which means it has set of methods for exchange of data among multiple threads and processes. It is based on shared data structures and meshes well with hardware architectures in which multiple cores share memory. However Java is susceptible to deadlocks. Deadlock is a condition under which the entire program is halted as each thread in a set attempts to acquire a lock already held by another thread in a set. Java is susceptible to deadlocks because (a) threads exchanges information by sharing variables that they lock with mutex locks and (b) the locking mechanism interacts with other language features, such as aliasing. Consider a simple banking transaction example...
Words: 3641 - Pages: 15
...Chapter 10 Transaction Management and Concurrency Control Discussion Focus Why does a multi-user database environment give us a special interest in transaction management and concurrency control? Begin by exploring what a transaction is, what its components are, and why it must be managed carefully even in a single-user database environment. Then explain why a multi-user database environment makes transaction management even more critical. Emphasize the following points: • A transaction represents a real-world event such as the sale of a product. • A transaction must be a logical unit of work. That is, no portion of a transaction stands by itself. For example, the product sale has an effect on inventory and, if it is a credit sale, it has an effect on customer balances. • A transaction must take a database from one consistent state to another. Therefore, all parts of a transaction must be executed or the transaction must be aborted. (A consistent state of the database is one in which all data integrity constraints are satisfied.) All transactions have four properties: Atomicity, Consistency, Isolation, and Durability. (These four properties are also known as the ACID test of transactions.) In addition, multiple transactions must conform to the property of serializability. Table IM10.1 provides a good summary of transaction properties. Table IM10.1 Transaction Properties. |Multi-user | |Single-user | |atomicity:...
Words: 4230 - Pages: 17
...A Distributed Transaction Management Scheme for Multidatabase Systems* Xinfeng Ye, Department of Computer Science, University of Auckland, New Zealand. Abstract finsaction management in a multidatabase sys- tem must ensure global serializability. Local seri- alizable execution is, by itself, not suficient to en- sum global serializability, since local serialisation or- ders of subtmnsactions of global transactions must be the same at all systems. In this paper a distributed tmnsaction management scheme is introduced. The scheme maintains autonomy of the local database systems. It is free from global deadlock, and, guar- antees fairness in the execution of the tmnsactions in the system. 1 Introduction A multidatabase system (MDBS) is a collection of pre-existing autonomous, and possibly heteroge- neous, local database systems (LDBSs). Transac- tions in an MDBS are of two types: Local transactions: Those transactions that only access data m,anaged by a single LDBS. Global transactions: Those transactions that ac- cess data managed by more than one LDBS. Transaction management in the MDBS is hierar- chical. Each LDBS controls the local transactions and the subtransactions of the global transactions at its site, and assures serializable execution at that site. The MDBS software controls the global trans- actions, and assures global serializability. Global serializability guarantees the correct con- current execution...
Words: 4732 - Pages: 19
...CSEN5322 – Operating Systems Homework-5 Student Name | Student ID | Section | Date | | | | | Bankers Algorithm The Banker's algorithm is a resource allocation and deadlock avoidance algorithm. Using C++ programming language, implement the Banker's algorithm for deadlock avoidance. 5 <= # of process, P0 ~ P4 4 <= # of resource, A ~ D 0 0 1 2 <= Allocation 1 0 0 0 1 3 5 4 0 6 3 2 0 0 1 4 0 0 1 2 <= Max 1 7 5 0 2 3 5 6 0 6 5 2 0 6 5 6 1 5 2 0 <= Available 5 <= # of process, P0 ~ P4 4 <= # of resource, A ~ D 0 0 1 2 <= Allocation 1 0 0 0 1 3 5 4 0 6 3 2 0 0 1 4 0 0 1 2 <= Max 1 7 5 0 2 3 5 6 0 6 5 2 0 6 5 6 1 5 2 0 <= Available Input a txt file that includes the number of processes, resources, and the matrixes for allocations, max, and available. Output Safe or Unsafe 1) Read the # of processes and the # of resources 2) Read allocation, max and available for each process and each resource 3) Print whether this system is safe or not to the output file. Data Structures for the Banker’s Algorithm Input.txt Input.txt Let n = number of processes, and m = number of resources types. Available: Vector of length m. If available [j] = k, there are k instances of resource type Rj available Max: n x m matrix. If Max [i,j] = k, then process Pi may request at most k instances of resource type Rj Allocation: n x m matrix. If Allocation[i,j] = k then Pi is currently allocated k instances...
Words: 406 - Pages: 2
...A Classic Problem - Dining Philosophers The Dining Philosophers problem is a classic OS problem that’s usuallu stated in very non-OS terms: There are N philosphers sitting around a circular table eating spaghetti and discussing philosphy. The problem is that each philosopher needs 2 forks to eat, and there are only N forks, one between each 2 philosophers. Design an algorithm that the philosophers can follow that insures that none starves as long as each philosopher eventually stops eating, and such that the maximum number of philosophers can eat at once. Why describe problems this way? Well, the analogous situations in computers are sometimes so technical that they obscure creative thought. Thinking about philosophers makes it easier to think abstractly. And many of the early students of this field were theoreticians who like abstract problems. There are a bunch of named problems - Dining Philosophers, Drinking Philiosophers, Byzantine Generals, etc. Here’s an approach to the Dining Phils1 that’s simple and wrong: void philosopher() { while(1) { sleep(); get_left_fork(); get_right_fork(); eat(); put_left_fork(); put_right_fork(); } } If every philosopher picks up the left fork at the same time, noone gets to eat - ever. Some other suboptimal alternatives: • Pick up the left fork, if the right fork isn’t available for a given time, put the left fork down, wait and try again. (Big problem if all philosophers wait the same time - we get the same failure mode as before, but repeated...
Words: 1511 - Pages: 7
...CS4321 Project 5: Transaction Processing System November 21, 2012 This project is due on November 29th, at 23:59pm via CMS. It is worth a total of 100 points. It counts for 25% of your grade. Read the whole assignment carefully, and review the relevant textbook materials, before you start implementing. The relevant material for this assignment can be found in Chapter 16 and 17 of the course textbook. The Big Picture Figure 1: A Simple Transaction Processing System 1 Overview In this assignment, you will implement a transaction processing system. The aim of the project is not to design a completely generic transaction processing engine but rather to give you a taste of the design decisions and challenges involved in doing so. You will be implementing transactions which can read, write and update values in a key-value store. As shown in gure , transactions access the key-value data stored in a "data page" through a linear hash index. The hash index in turn uses the buer manager to fetch the appropriate pages from the disk. We will provide you with a implementation of a linear hash index in the form of a library. Note that as long as the interface for the index is the same, the linear hash index may as well be replaced by a B+-tree index like the one which you implemented in the previous assignment. However, the B+-tree assignment you implemented does not support concurrent modication and hence cannot be used here directly. The linear hash index which is provided...
Words: 2665 - Pages: 11
...The Deadlock Problem Law passed by the Kansas Legislature in early 20th century: “When two trains approach each other at a crossing, both shall come to a full stop and neither shall start upon again until the other has gone.” Neil Groundwater has the following to say about working with Unix at Bell Labs in 1972: ... the terminals on the development machine were in a common room ... when one wanted to use the line printer. There was no spooling or lockout. pr myfile > /dev/lp was how you sent your listing to the printer. If two users sent output to the printer at the same time, their outputs were interspersed. Whoever shouted. “line printer!” first owned the queue. 1 Deadlock or Deadly Embrace Permanent blocking of a set of processes that either compete for system resources or communicate with each other – Several processes may compete for a finite set of resources – Processes request resources and if a resource is not available, enter a wait state – Requested resources may be held by other waiting processes – Require divine intervention to get out of this problem A significant problem in real systems, because there is no efficient solution in the general case Deadlock problem is more important because of increasing use of multiprocessing systems (like real-time, life support, vehicle monitoring, multicore utilization, grid processing) Important in answering the question about the completion of a process Deadlocks can occur with – Serially reusable...
Words: 282 - Pages: 2
...ABSTRACT The purpose of this study is to get hold of relevant information with the gathered data from the barangay Punta Prinsesa, Cebu City; to accumulate secondary data and other necessary information about the said barangay and verify the information at hand; to identify the community’s assets, needs, opportunities and threats; to list down and infer the community’s assets, needs, opportunities and threats from the households or residents; to outline the community’s assets, needs, opportunities and threats; to categorize the assets, needs, opportunities and threats given by the respondents; and to congregate and analyze the gathered data. In addressing to the documents needed for our research, we used transect mapping, structured questionnaire data for the interview, thorough study and lines of research to come up with the necessary information as regards to the community’s assets, needs, opportunities and threats. With the conclusion that we have reached, it has been found out that women are more active in participating in such environmental activities. Also, citizens aging from the range of 40-75 years old are more concerned of the surroundings and the environmental involvement occurring in their barangay than the young citizens do. In addition, all of our respondents are aware of the environment as well as the things to be made for the betterment of their place. Overall, they are all willing to participate and volunteer to make an action towards a healthier environment...
Words: 340 - Pages: 2
...Server Error in '/' Application. [pic] Transaction (Process ID 750) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Transaction (Process ID 750) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. Source Error: |An unhandled exception was generated during the execution of the current web request. Information regarding the origin and | |location of the exception can be identified using the exception stack trace below. | Stack Trace: | | |[SqlException (0x80131904): Transaction (Process ID 750) was deadlocked on lock resources with another process and has been | |chosen as the deadlock victim. Rerun the transaction.] | |System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1951450 | |System.Data.SqlClient.SqlInternalConnection.OnError(SqlException...
Words: 294 - Pages: 2
...1. Deadlock (“deadly embrace”) is a system-wide tangle of resource requests that begins when 2 or more jobs are put on hold. • Each job is waiting for a vital resource to become available. • Needed resources are held by other jobs also waiting to run but can’t because they’re waiting for other unavailable resources. • The jobs come to a standstill. • The deadlock is complete if remainder of system comes to a standstill as well. • The resources can be categorized into physical and logical resources. The physical resources are printer, disk drive, cpu, memory, scanner etc. The logical resources are files. • Deadlock is more serious than indefinite postponement or starvation because it affects more than one job. • Because resources are being tied up, the entire system (not just a few programs) is affected. • Requires outside intervention (e.g., operators or users terminate a job) to resolved the deadlock. 2. Seven Cases of Deadlocks Case 1 Deadlocks on file requests Case 2 Deadlocks in databases Case 3 Deadlocks in dedicated device allocation Case 4 Deadlocks in multiple device allocation Case 5 Deadlocks in spooling Case 7 Deadlocks in disk sharing Case 8 Deadlocks in a network Case 1: Deadlocks on File Requests | |If jobs can request and hold files for duration of their...
Words: 3058 - Pages: 13
...Resource Allocation Graphs Roger Henriksson Department of Computer Science Lund University The possibility of deadlock is an undesired property (to say the least) of safety-critical real-time systems. Therefore, a method to verify that a system cannot deadlock, or to detect possible deadlock situations, is of tremendous value. One such method is resource allocation graphs. As stated in Operating System Concepts by Peterson and Silberschatz [PS85], the occurrence of deadlock requires among other things that hold-wait situations exist and a circular chain of such hold-waits must exist. A resource allocation graph attempts to graphically illustrate all the hold-wait situations in a system. In this graph it is possible to search for cases of circular hold-wait. In their book, Peterson and Silberschatz [PS85] (Section 8.2.2) introduce a method for drawing resource allocation graphs. However, in their version the resource allocation graph shows all the hold-wait-states that exist at any one given point in time. This is a good tool for illustrating a transient state in the system, but in order to use their version of the graphs for detecting any possible deadlock situation we would have to draw a graph for each and every possible combination of execution state for all threads in the system. Then, each and every one of these graphs would have to be analysed for cycles indicating circular wait. This is clearly unpractical. Instead, we modify the method of drawing resource...
Words: 1937 - Pages: 8
...sections Different solutions, on different levels of abstraction „Correctness“ criteria (mut.ex., progress/non-starvation, fairness, bounded waiting) Busy wait vs. Sleep Classical synchronization problems Bounded Buffers Readers/writers Dining Philosophers Atomic transactions (cf. databases) Logging, UNDO/REDO recovery Concurrency Control, Serializability, Locking Time-Stamping Operating System Principles Syllabus.6 Silberschatz, Galvin and Gagne ©2005 Chapter 7: Deadlocks Define the problem, give necessary conditions! Graph-based models (single vs. multiple resources per type) Resource Allocation Graph Wait-For Graph Prevention What Methods for handling deadlocks can we do to ensure that no deadlock can ever occur? can we detect that the system/some processes is/are in a deadlock state? we detected a deadlock: how to resolve the situation? Detection How/when Recovery from deadlock If Operating System...
Words: 624 - Pages: 3
...Notes on DBMS Internals Neil Conway neilc@samurai.com November 10, 2003 Preamble These notes were originally written for my own use while taking CISC-432, a course in DBMS design and implementation at Queen’s University. The textbook used by that class is Database Management Systems, 3rd Edition by Raghu Ramakrishnan and Johannes Gehkre; some of the material below may be specific to that text. This document is provided in the hope that it is useful, but I can’t provide any assurance that any information it contains is in any way accurate or complete. Corrections or additions are welcome. Distribution Terms: This document is released into the public domain. Query Evaluation External Sorting • A DBMS frequently needs to sort data (e.g. for a merge-join, ORDER BY, GROUP BY, etc.) that exceeds the amount of main memory available. In order to do this, an external sort algorithm is used. • 2-Way External Merge Sort: – In the first pass, each page of the input relation is read into memory, sorted, and written out to disk. This creates N runs of 1 page each. – In each successive pass, each run is read into memory and merged with another run, then written out to disk. Since the number of runs is halved with every pass, this requires log2 N passes. Since an additional initial pass is required and each pass requires 2N I/Os, the total cost is: 2N( log2 N + 1) – Thus, we can see that the number of passes we need to make is critical to the overall performance of the sort (since in...
Words: 12979 - Pages: 52
...This assignment verifies that you understand how shared and exclusive locks work. Suppose that S1, S2, and S3 are sessions connected concurrently to the same database instance. Suppose further that D1, D2, and D3 are data objects that can be locked with a shared and exclusive lock. For the ten locking situations below, indicate, for each session, whether it procures the requested lock, waits, or deadlocks. S1 has a shared lock on D1 and S2 attempts to procure a shared lock on D1. Since s1 has a shared lock on D1 and the other sessions can procure the lock without any waiting for release by s1.so s2 can procure a shared lock on D1 * S1 has an exclusive lock on D1 and S2 attempts to procure a shared lock on D1. * Since S1 has a exclusive lock on D1 any other sessions cannot procure a shared lock on D1.The other sessions has to wait till S1 releases the lock. so S2 has to wait until S1 releases exclusive lock on D1 S1 has a shared lock on D1 and S2 attempts to procure an exclusive lock on D1. * Since exclusive locks can be made on a data instance only when its not accessed by any other sessions.S2 must wait until S1 commits in order to procure an exclusive lock on D1 S1 has an exclusive lock on D1 and S2 attempts to procure an exclusive lock on D1. * Since exclusive locks can be made on a data instance only when other sessions have not made shared lock or exclusive lock on that data instance. so S2 must wait to begin until S1 commits in order to procure...
Words: 672 - Pages: 3