QuickStudy: Transactional Memory

Programmers are learning new ways to code for multicore computing systems.

With the increasing use of multicore CPUs in computers, programmers have to learn new techniques for parallel processing. One very promising approach is transactional memory.

The primary problem for programmers is that multiple programming threads that are executed simultaneously by different processors must often access the same memory or stored data. It is difficult to determine in advance which thread will write its results first. If one thread changes data in memory, that may invalidate another thread's processing.

Thus, the system needs to make sure that the correct write operations take place at the proper time, without interference, disruption or undue degradation of performance.

Definition:

Transactional memory is a programming approach for multiple CPUs designed to ensure that updates to shared memory are performed without interrupting or invalidating other code. Data changes are encapsulated in transactions and committed to memory only when safe -- that is, when it's clear that they will not interfere with other code. If two or more updates will change the same location, those transactions are rejected, no changes are made, and each transaction must try again until it succeeds.

To accomplish this, transactional memory runs code as "atomic blocks" inside a transaction, and all memory reads and writes are isolated until they are determined to be safe. Atomic here means that the code runs without interruption. When an atomic block completes, the system rechecks memory and looks for conflicts. Finding none, it executes the write operations, and these results become visible to the entire system.

If the system detects conflicts, however, it discards the transaction log and re-executes the block. When the contending threads are re-executed, they may proceed in a different order, thereby solving the conflict. While not exactly elegant, this solution seems to work well enough.

If an exception or error is somehow not handled inside the atomic block, all updates that block would make are automatically tossed away.

Where to find transactional memory systems

Sun Microsystems's forthcoming Rock family of multithreading, multicore Sparc microprocessors, expected to debut in 2009, will include hardware support for transactional memory. A programming approach Sun calls "hybrid transactional programming" will take advantage of the new hardware when available while hiding its limitations. For details about this, see "Hybrid Transactional Memory," by Peter Damron, Alexandra Fedorova, Yossi Lev, Victor Luchangco, Mark Moir and Daniel Nussbaum at research.sun.com.

And Microsoft Research is doing significant work on transactional memory, including adding support for existing languages such as C# and new languages such as Haskell and Atomos. For more information, see research.microsoft.com.

More about: Microsoft, Rock, Sun Microsystems
References show all

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
Users posting comments agree to the Computerworld comments policy.
Login or register to link comments to your user profile, or you may also post a comment without being logged in.
Related Coverage
Related Whitepapers
Latest Stories
Community Comments
Tags: programming
Whitepapers
All whitepapers
Sign up now to get free exclusive access to reports, research and invitation only events.
Featured Download
/downloads/product/145/microsoft-security-essentials/

Microsoft Security Essentials

Microsoft Security Essentials provides your home PC with real-time protection. It constantly uses the latest technology ensuring that you will always stay up to date ...

Computerworld newsletter

Join the most dedicated community for IT managers, leaders and professionals in Australia