#Two-Phase Locking
##Conservative Two-Phase Locking
- It is a concurrency control method that guarantees serializability.
- The whole list of transactions are know beforehand.
- All the locks are aquired at start of each transaction.
- This ensure no deadlock.
##Basic Two-Phase Locking
- It is a concurrency control method that guarantees serializability.
- The whole list of transactions are know beforehand.
- Locks are aquired as required by each transaction.
- Deadlock prevention is implemented using two strategies: Wait - die and Wound - wait
- Clone the repository
git clone https://github.com/Mukarr/Two-Phase-Locking.git
cd cd Conservative-Two-Phase-Locking
- Random input transactions generation
python3 generate_tx.py -x [num_transactions] -i [max_instructions] -t [max_time] -v [num_variable]
num_transactions: Total number of transactions to the system.
max_instructions: Maximum number of instruction any transaction can generate.
max_time: Maximum time till which system proceeds.
num_variable: Total number of variable in the system.
- Conservative two-phase Locking
python3 twophase_locking_conservative.py [--verbose]
verbose_output: Print output to screen verboselly
- Basic two-phase Locking with wait-die strategy
python3 twophase_locking_wait_die.py [--verbose]
verbose_output: Print output to screen verboselly
- Basic two-phase Locking with wound-wait strategy
python3 twophase_locking_wound_wait.py [--verbose]
verbose_output: Print output to screen verboselly
All these will take the input generated by generate_tx.py.
python3 generate_tx.py -x 5 -i 10 -t 10 -v 5 | python3 twophase_locking_conservative.py --verbose
-
This will generate a system with 5 transactions, each with maximum of 10 instructions, with 5 variable in total and the system's lifetime being 10 seconds.
-
This random set of transactions is piped to
twophase_locking_conservative.py, which generates the required schedule.