我正在运行一个有 2 个线程的应用程序。一个线程保存图像从相机抓取,另一个线程处理图像,这里的问题是,处理线程在一些(每次运行时随机)小时后在处理过程中停止(停滞或阻塞无法获取) ,但它在带有 windows7 的 i3 和带有 windowsXp 的双核处理器上运行良好。两个线程中都没有临界区或锁。请帮我解决这个问题。
线程2的代码:
fn_Waitforfiles(); // while loop waits until the 4 images saved in watch folder if not it will return at count of 50
CString strLog = "";
strLog.Format("Entering Skipping..");
for(int d = 1; d <= m_iInterLeave; d++)
{
m_ifileCount++;
m_strcurFilePath.Format("%s\\%lu.jpeg", m_strToProcessDir, m_ifileCount);
if(PathFileExists(m_strcurFilePath))
::DeleteFile(m_strcurFilePath);
else
{
m_ifileCount--;
m_strcurFilePath.Format("%s\\%lu.jpeg", m_strToProcessDir, m_ifileCount);
}
if(d == m_iInterLeave)
{
m_ifileCount++;
m_strcurFilePath.Format("%s\\%lu.jpeg", m_strToProcessDir, m_ifileCount);
}
}
strLog = "";
strLog.Format("Skipped %d images on Interleaving..", m_iInterLeave);
MSSLOGGER::WriteLog(_T(strLog));
写入日志“Enter Skipping..”后,thread2 不再运行
最佳答案
线索可能在“观看文件夹中的图像”。这听起来像是您依赖于文件更改通知,而且这些通知可能会被遗漏(更准确地说,其中许多通知可能会合并为一个摘要通知)。
关于c++ - i7 处理器与 windows8 操作系统的多线程问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18010934/