Producer consumer that simulates the interaction of threads controlling a hardware device
I have some minor things to point out:


There is not a single empty line in this code, and this essentially looks like globals, functions, and comments stacked on top of each other.  You should have each type separated so that the code is easier to read (especially with the function names and return types on separate lines).
Since you're using C++11, you should be using &lt;random&gt; in place of std::rand.  It has been determined that rand() is harmful and should no longer be used in C++11.
Unless I'm misunderstanding the use of multithreading here, I don't think you should be using any global variables, as they're prone to bugs.  If that's the case, then you should just be passing them to functions as needed.  If not, then at least put them all towards the top (they're already global, so it doesn't make a difference to have them in different places outside the functions).
You don't need to be using std::endl everywhere.  It doesn't appear that you're needing to flush the buffer each time, which can also affect performance.  Instead, output a "\n" to produce a newline without also flushing the buffer.