Previous | Next --- Slide 28 of 64
Back to Lecture Thumbnails
scedarbaum

I think this was mentioned in lecture, but one way to solve this is to put an ordering on the objects being locked (bank accounts, in this examples). For instance, if each bank account had a unique integer ID, just ensure that you always lock the accounts in an increasing order (e.g., if ID(x) = 100 and ID(y) = 101, always acquire x's lock before y's).

ekr

This is similar to the solution to the graph problem on the Practice Exam 2. In the review session it was mentioned that the simplest solution to prevent deadlock would just be to order each node's neighbors (including itself), and lock them in that order.