• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubt in Locking

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am done with the coding of my project..URLYBird 1.1.2.It took me 120 hrs approx.
I have a requirement for my lock method which states that:
"If the specified record is already locked by a different
client, the current thread gives up the CPU and consumes no CPU cycles until the record is unlocked".

I have implemented timeout and reentrant locks in my reservation lock manager class . I think that if a thread conditionally waits for a short timeout or until a lock is released (whichever comes earlier) would not consume CPU cycles,since after the timeout the thread gives up as opposed to blocking continously until the lock is released.


Is my understanding correct ?
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you should NOT use timeouts based on my understanding from the Monkhouse's book and posts.
Pay attention to the part where it says "by another client" if it is written in the assignment this means that if the client is trying to lock a record that is already locked by itself the client should not wait.
 
rohan tiwari
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks..
I have removed timeouts.
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like you my solution used the ReentrantLock and Condition classes, NO timeouts.
I obtained 80/80 in the locking portion of the exam. Sounds like your taking a good approach.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic