How to improve two threads switching effecitiveness
I developed a broadcast stream server using VC6.0.
There are two threads, reader thread reads data to a FIFO, output thread reads data from the FIFO. When the empty, I used suspend() to suspend the output thread, and resume() the reader thread.
But I found that when the two thread switch, it costs a lot of time . and this leads to my server can not output stream correctly.
1. I don't know how I can improve the switching effectiveness.
2. Is there any better method to watch the FIFO's condition to avoid the FIFO being full or empty?
3. For the server must run endless until receving a stop signal, I use a while loop in my reader thread, and output thread, but it cause sometimes data racing. Are there some other ways to implement this function?
Thx.
the following is the part of my program:
e.g:
thread switching:
if(nSize == 0)
{
((CTsStreamerView*)m_pMain)->PostMessage(WM_FIFO_EMPTY, NULL, NULL); //send message to the view and resume the reader thread.
((CTsStreamerView*)m_pMain)->m_nOutputThreadState = THREAD_SUSPEND;
this->SuspendThread();
}

