About
Subscribe

Don`t let multi-threading deadlock applications

Johannesburg, 27 Jan 2004

The introduction of multi-threading technology to computer processors is a great leap forward in terms of performance, but it can wreak havoc on application behaviour.

Simply put, this technology allows a processor to handle several tasks simultaneously, increasing the efficiency of the chip and resulting in faster processing.

"Using threads in an application offers some significant advantages in many respects, but opens up an entirely new realm of potential problems," says Paul Wandrag, technical consultant at Compuware Corporation SA.

He points out that in order to improve performance and to make the best use of available processing power, developers are increasingly using multiple threads in complex C and C++ applications.

However, multi-threaded applications open the door to difficult-to-diagnose thread coordination problems that can lead to deadlock - commonly experienced as an application freeze or poor performance.

"The primary problem with writing multi-threaded applications is that there are parts of the code that access limited and shared resources that only one thread can execute at a time. If multiple threads contend for the same resources, and you don`t properly protect those resources, you could end up with corrupt data and consequent fatal application errors," he explains.

But there is a more common and insidious problem with multi-threaded applications.

This comes from the fact that threads often access multiple shared resources at the same time in order to execute. It is possible for threads to obtain some of the resources they need to execute, but be blocked - by other threads - from getting all of the resources they need. As a result, no thread can continue executing."

This deadlock can freeze up portions of the application, or hang the entire application, forcing a shutdown.

"These are some of the most difficult programming errors to find, diagnose and correct, because they can occur randomly, and even at different points in execution," says Wandrag.

To address this issue, Compuware has introduced functionality into its DevPartner Studio application-testing solution to identify and address these types of subtle errors.

"DevPartner Studio can assist developers building multi-threaded applications by identifying real or potential deadlocks, and providing the information needed to pinpoint the cause of the deadlocks and where the code has to be fixed," says Wandrag.

DevPartner Studio`s deadlock analysis feature provides an automated method to search for deadlocks, potential deadlocks and other resource and critical section synchronisation errors in applications written in C and C++. The deadlock analysis will report a potential deadlock when it notices that an application is not accessing resources in a safe manner, while monitoring all synchronisation objects in multi-threaded applications to provide notification before the actual deadlock occurs.

DevPartner Studio also provide detailed information describing how the actual deadlock will occur, making it easier to modify code to prevent the problem from occurring.

Share

Compuware

Compuware Corporation, a multibillion-dollar company, provides business value through software and professional services that optimise productivity and reduce costs across the application lifecycle. Meeting the rapidly changing needs of businesses of all sizes, Compuware`s market-leading solutions improve the quality, ease the integration and enhance the performance of distributed, e-business and enterprise software. For more information about Compuware, please contact the South African subsidiary on +27 (0)11 516-2900 or visit Compuware SA on the World Wide Web at http://www.compuware.co.za.

Editorial contacts

Peter Mashigo
Citigate ICT PR
(011) 804 4900
Peter.Mashigo@Citigatesa.com