Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a test framework for C that forces race conditions?

Tags:

c

concurrency

Does there exist a test framework for C that forces race conditions?

Or for C++ and Java, for that matter.

like image 572
James Lim Avatar asked Nov 29 '11 18:11

James Lim


People also ask

What type of testing is needed to detect a race condition?

Race conditions are inherently a result of non-determinism. If you cannot ensure that the calling sequence is secure, then introduce a number of run-time checks that verify the protocol invariants are honoured. Then, at least you will have evidence of a fault whenever they occur.

How can C race conditions be prevented?

To avoid race conditions, any operation on a shared resource – that is, on a resource that can be shared between threads – must be executed atomically. One way to achieve atomicity is by using critical sections — mutually exclusive parts of the program.

How do you determine race conditions?

Basically, people detect race condition problem in two big category methods. The first one is detecting in the compile time, which is also called static detection; the other is detection in the run time, which is called dynamic detecting. Both of these two have shortcomings such as coverage, speed, etc.

Which tool will help us detecting possible race conditions in a program?

Race Detection Algorithms. The lockset algorithm, used in both static and dynamic analysis tools, reports a potential race when shared memory is accessed by two or more threads without the threads holding a common lock.


1 Answers

The Valgrind tool Helgrind detects (among other things) data races in C or C++ programs that use pthreads.

like image 77
Roland Avatar answered Sep 25 '22 07:09

Roland