• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Locking mechansim

 
John Canavan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Apart from what I had to learn for the programmer exam, I do not have any real experience of multi-threading programming so I want to keep the locking mechanism I use in the project as simple as possible. I would like to use a mechanism similar to the one in Max’s book (i.e. keeping track of a the locked records in a static vector) and have a couple of questions based on it (the project I am doing is Bodgitt and Scarper, version 2.3.3).
1.Is this mechanism suitable for this project?
2.What happens if a client goes down before the lock is released (i.e. client goes down between db.reserveDVD(upc) and db.releaseDVD(upc)? Do locks get released in this case? Are there any other issues with this mechanism.
As I said I don’t have any real experience in this area, so any help is appreciated.
Thanks in advance,
John
 
Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,
Is this mechanism suitable for this project?

I don't know how the Bodgitt and Scarper assignement ( I have URLyBird) but I think there are a lot of similarities. My design is also quite similar to Max. You can have a look on it at NX: URLYBird / my approach of the reading problem . I'm not through, I'm still fighting, but there you can get a lot of ideas.
2.What happens if a client goes down before the lock is released (i.e. client goes down between db.reserveDVD(upc) and db.releaseDVD(upc)? Do locks get released in this case? Are there any other issues with this mechanism.

That's the point here. Some people implement a way to prevent dead lock when a client crashes, other not, arguing that it's not part of the requirements. If you are interested in this topic, I would search for threads discussing WeakHashMap, WeakReferences and Unreference (interface).
There you can read a lot about it.
Greetings
Ulrich
 
Jamy Wang
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, John
Could you describe the mechanism in the MAx's book? Because I dont see that book. Thank you.
Regards
James
 
John Canavan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for that Ulrich.
Hi James, if you visit the thread that Ulrich supplied a link to then you will learn more about the locking mechanism Max used in his book.
Hope that is ok,
John
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic