Hi,
I'm testing a small program that in a tight (busy) loop checks that another
thread has reached some specific state.
With valgrind, this runs forever on some machines, and returns pretty soon on
other (much slower) machines.
Is this a known problem and is there a workaround?
I'm running Valgrind-3.7.0.
Here's the program, and everything works fine with valgrind if I add a sleep in
the loop (HERE).
Detlef
#include <thread>
#include <condition_variable>
#include <mutex>
using std::mutex;
using std::unique_lock;
bool started = false;
bool running = false;
mutex startedMtx;
mutex runningMtx;
std::condition_variable runningCond;
void foo()
{
running = true;
{
unique_lock<mutex> lock(startedMtx);
started = true;
}
unique_lock<mutex> lock(runningMtx);
while (running) {
runningCond.wait(lock);
}
}
int main()
{
std::thread t(&foo);
bool goOn = false;
while (!goOn) {
unique_lock<mutex> lock(startedMtx);
goOn = started;
// HERE
}
{
unique_lock<mutex> lock(runningMtx);
running = false;
runningCond.notify_one();
}
t.join();
return 0;
}
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users