I am supposed to do this but I have no idea what to do. Implement deadlock detection:
Question:
I am supposed to do this but I have no idea what to do.
Implement deadlock detection: Assume you have a database management system that implements a locking mechanism. You are running a deadlock detection mechanism in the background to detect and abort transactions that are blocked in a deadlock.
Input: An input file, input.txt with the schedule of transactions in format
Ti:Action(Resource)
i: a number identifying the transaction
Action: R: Read, W: Write, X: Exclusive Lock, S: Shared Lock, C: Commit, A: Abort
Resource: Any string denoting a shared resource (assume tuple level granularity)
that shows actions in interleaved transactions, including their acquisition and release of the locks. This file is provided as a simple way to simulate the view of your background deadlock detection mechanism of the action orders in transactions happening in the system.
Your program tests if the schedule causes a deadlock. In case of a deadlock, it chooses the transaction with the fewest number of locks to abort. If the number of the locks are the same, it chooses the youngest (latest to start) transaction.
Example:
T1:S(A) T1:R(A) T2:X(B) T2:W(B) T1:S(B) T3:S(C) T3:R(C) T2:X(C) T4:X(B) T3:X(A)
Output:
OK, if the given schedule does not include deadlocks.
The transaction to break the deadlock, otherwise.
Example:
T3
Which shows your deadlock detection suggests aborting T3 in order to resolve the deadlock in this schedule.
This is all I was given. Please only answer if you know what to do.
Accounting Information Systems
ISBN: 978-1133935940
10th edition
Authors: Ulric J. Gelinas, Richard B. Dull