in reply to Re^7: need a thread to wait until a buffer is full.
in thread need a thread to wait until a buffer is full.

They aren't signals in that sense of the word. In the sense of cond_signal().

Basically, the thread in waiting on cond_wait() will not be allocated any timeslices by the scheduler until the other thread calls cond_signal() (or broadcast). So, no polling a second shared var to see if the first is ready yet.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^9: need a thread to wait until a buffer is full.
by zentara (Cardinal) on Jul 26, 2007 at 12:57 UTC
    I'll have to look into that, but if the thread waits (without any timeslices) for the cond_signal from the other thread, that would limit it to watching only 1 thread. The way I envisioned it, the controlling thread could ask many other threads to fill their buffers simultaneously, and then go into a loop to harvest them as they come in, and still do other things as well, like asking for more buffer-filling.

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
      but if the thread waits (without any timeslices) for the cond_signal from the other thread, that would limit it to watching only 1 thread.

      No, that is not so. The variable upon which the cond_wait() is waiting can be cond_signal()ed from any thread (that has a lock on the variable).

      Also, if more than one thread are in a cond_wait() state on the same variable, one of them (non-determanistically) will be awoken.

      You can also signal a variable using cond_broadcast(), in which case all threads currently blocking on that variable will be woken up, rather than just one.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.