
March 27th, 2008, 08:37 AM
|
|
Registered User
|
|
Join Date: Mar 2008
Posts: 2
Time spent in forums: 15 m 20 sec
Reputation Power: 0
|
|
|
Coverity Prevent- source code analysis tool for debugging software defects easily
Hi ,
To find solution for your problem lets see what dead lock is . A deadlock is a situation where threads are blocked because one or both are waiting for access to a resource that will not be freed. The application can never terminate because the threads are blocked indefinitely.
This behavior results from improper use of the synchronized keyword to manage thread interaction with specific objects. The synchronized keyword ensures that only one thread is permitted to execute a given block of code at a time. A thread must therefore have exclusive access to the class or variable before it can proceed. When it accesses the object, the thread locks the object, and the lock causes other threads that want to access that object to be blocked until the first thread releases the lock.
Since this is the case, by using the synchronized keyword you can easily be caught in a situation where two threads are waiting for each other to do something.
Of course, most deadlocks won't be quite so obvious simply from reading the source code, especially if you have a large multithreaded program. A good Source code analysis tool, like Coverity Prevent, finds deadlocks and points out their location in the source code so that you can fix them. Coverity has customers like Symbian, RIM (Blackberry), Juniper networks, Cisco, Texas instruments and is also used by the Department of Homeland security to scan lots of open source projects. You can get more info at Coverity web page.
|