You are on page 1of 7

Challenge of Race Conditions in Parallel Programming

Introduction
The most challenging issue in parallel programming - race conditions. A race condition is a programming fault which produces unpredictable program state and behavior due to un-synchronized simultaneous executions.

Data Race Condition Problem


A data race condition occurs when multiple threads access a shared memory location with an undetermined accessing order and at least one access is to write a new data into the shared memory location. Benign Data Race Condition : Data race condition that is not harmful.

Example
total_count += group_count where, total_count is a global static variable shared by all the working threads.

General Race Condition


A general race condition is caused by an undetermined sequence of executions that violates the program state integrity and cannot be attributed to a single memory location access. Data race conditions are simple form of general race conditions.

Avoiding Race Condition Problems


Use passing-by-data-value instead of passing-by-pointer Design the data structure to limit the global variable usage Analyze the program state, input set, and run-time environment to decide if a race condition is a real program bug. Focus on fixing the real program bug instead of fixing a race condition at the surface level. When a thread or a process causes a transitory state occurring on some program objects, avoid another concurrent thread or process operating on the same objects in parallel.

You might also like