I have been converting an existing make based build system over to cmake,
and overall I am loving it so far.

I happened to run across CheckForPthreads.c, and was a little surprised to
see that it was basically a classic example of racy code.

The two spawned threads both increment res, which is then used as the return
value of the whole program. So to prove to myself that this was a real
issue, not just theoretical raciness, I compile the program, and ran it a
couple million times on my linux box, and 7 of those two million runs
returned 1 instead of 2. So the chance of screwup is quite small, but
definitely non-zero.

Looking over the source I have a few questions:
Should it protect the increment with a mutex?
Or, should it really just spawn 1 thread? Is there a point to the spawning
two?
Is there a purpose to all the prints?
What is the line "if(ac > 1000){return *av[0];}" there for? If it has a
purpose that definitely deserves a comment.
What about the "#if defined(__BEOS__)"... lines? The usleep will only be
there on BEOS, but the comment on the usleep line mentions sun.

Kevin
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to