This is the mail archive of the
mailing list for the pthreas-win32 project.
Question about condition variable
I am developing a software based on win32-pthreads (latest available).
My problem I encountered is:
I have an object for message queuing, wich is intended to let the
callers thread wait by getMessage(LPSSMSG lpMsg), until a new
message is posted by any other thread. Now imagine, the thread
which is waiting for new messages is in status ACTIVE (sleeping or
not running) in operating system. The thread wich is posting a new
message is in status RUNNING. This running thread pushes at first
a new message into the queue and signals the waiting thread to be
waked up and unlocks the mutex immediately, so that other threads
can push further new messages.
Now, the problem is when the signal is given to wake up the waiting
thread by the first message pushing thread then the OS dont switch
automatically its thread execution. This means if the thread is not
waked up, because it is not switched to stutus RUNNING and an other
thread pushes further new message in to the queue and signals also
the waiting thread then what is about the first and second signals?
I am actually switching thread execution with sleep(0) function,
after each message posting.