Forums Register Login

B&S: Testing Locking

+Pie Number of slices to send: Send
Hello Everybody !


I am just looking for good ideas/suggestions on testing multi-threaded code. I think I have a decent locking mechnanism ready but want to test it vigorously before going any further. Is there any good literature already out there on testing deadlocks, starvation, race conditions etc.

Ofcourse personal experiences (& lessons learnt) on testing locking would be greatly appreciated.

Thanks
+Pie Number of slices to send: Send


The above code is almost identical to someone elses posted on this forum.

Notes:

1/ As the code stands it spawns 33*10 threads, this is alot, too many for most RMI implementations, if you replace db with your remote stub and use that it will probably fall over, so reduce the 10 value to 2 for RMI.

2/ The 33 value is the number of rows in your table so you need to modify that.

3/ The above code guarantees a single DB object, you may want to make sure your code guarantees this on its own, depending on your design. Simply make the db non-static to test this.

4/ The code creates a lot of logging! So use java.util.logging or reduce it, or you will likely crash your PC. Also note FINE is not logged by default, you need to do - see below

5/ Add code or manually edit file so that your customer field is equal to "0"

6/ The end result is to that every record should end up customer field == 10*200. If not something is amiss. Also check very carefully that all the other fields are not corrupted, as this code also tests your RAFWrappers thread-safety.

7/ If you don't use cookies it's a simple mod in the code above.

java.util.logging setup if you haven't used it before.
otherwise default uses flippin XML




Have fun
+Pie Number of slices to send: Send
 

Originally posted by Udham Singh:
Hello Everybody !


I am just looking for good ideas/suggestions on testing multi-threaded code. I think I have a decent locking mechnanism ready but want to test it vigorously before going any further. Is there any good literature already out there on testing deadlocks, starvation, race conditions etc.

Ofcourse personal experiences (& lessons learnt) on testing locking would be greatly appreciated.

Thanks



You definitely need a multithreaded tester, such as the one Mike posted. Another thing you should do is insert random delays into (or around) your file access code. It is quite possible for locking code to appear to work perfectly when the system is very fast and fall over when it slows down, since this introduces more room for race conditions. Note that most file activity on modern systems is cached by the Operting System and runs very fast, this won't be the case over a network, or if using a conditioned OS as might happen in Sun's testing.
A magnificient life is loaded with tough challenges. En garde tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 573 times.
Similar Threads
Locking - synchronized
Application Testing tools and tests
a simple question of Locking mechanism
Urly Bird, Passed SCJD with 400
urlyBird testing lock
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 02:39:30.