对磁盘的openmp写入是否线程安全

Is openmp writing to the disk thread safe?

本文关键字:是否 线程 安全 磁盘 openmp      更新时间:2023-10-16

我的c++程序伪代码如下:

#omp pragma parallel
for (i=1...100000)
  write input files into a file called "$i.txt", $i is the value of i
  then do ./outside_program $i.txt and reads its inputs and do other stuff

假设./outside_program线程安全。使用openmp写不同的文件在C++线程安全吗?

如果你正在写不同的文件,我认为没有问题,它是线程安全的。事实上,这个问题与您使用的多线程API无关。OpenMP、TBB或其他技术…