570 views
0 votes
0 votes
In an electronic funds transfer system, there are hundreds of identical processes that work as follows. Each process reads an input line specifying an amount of money, the account to be credited, and the account to be debited. Then it locks both accounts and transfers the money, releasing the locks when done. With many processes running in parallel, there is a very real danger that a process having locked account $x$ will be unable to lock $y$ because $y$ has been locked by a process now waiting for $x.$ Devise a scheme that avoids deadlocks. Do not release an account record until you have completed the transactions. (In other words, solutions that lock one account and then release it immediately if the other is locked are not allowed.)

1 Answer

0 votes
0 votes
We can number the accounts to avoid circular wait. Process acquires lock in increasing order of account number.  No deadlock possible now as we are providing a order in which resources can be requested.

Related questions

0 votes
0 votes
1 answer
3