c++ - i7 处理器与 windows8 操作系统的多线程问题

标签 c++ multithreading windows-8 multicore

我正在运行一个有 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/

相关文章:

windows-8 - 在 Windows 8 上同步 indexedDB 的策略

c++ - Qt 中低延迟音频合成的最佳多线程方法是什么?

c++ - 常量指针数组

c++优先顺序 - 在乘法之前进行类型转换

c++ - 可能的 header 冲突

java - java 中带有外部 API 对象的线程安全

python - 使用带 raspi 相机的 flask 进行视频流传输

c++ - openMP - 与 for 循环和私有(private)并行化

android - SOAP 过时了吗?

c# - 用户单击 MessageDialog 上的按钮时如何调用 FileSavePicker?