问题描述
大家好,
我在C中使用VS2010 Prof功能,它读取1个数据文件(来自1000个数据文件),做一些分析并写入一些数据文件在另一个目录中,然后继续读写到最后。通常我的函数是myfunc(int start_index,int end_index,char * read_file_directory)。为了改善运行时间我使用_beginthread创建了5个线程,每个线程调用myfunc,如下所示:
线程1:myfunc(1,200,read_directory)
线程1:myfunc(201,400, read_directory)
线程1:myfunc(401,600,read_directory)
线程1:myfunc(6011,800,read_directory)
线程1:myfunc (801,1000,read_directory)
myfunc工作得非常好,超过1000个文件,我用Visual Leak Detector 2.3检查了它,但它没有显示内存泄漏。一旦使用多线程,我的程序就会给我访问冲突。我写了一些小函数,并在myfunc中调用它们,我也在使用CLAPACK(32位发行版)和fftw3f。我完全糊涂了,是什么原因?如何解决它的任何帮助表示赞赏。
Hello all,
I have function in C using VS2010 Prof, which reads 1 data file(from 1000 data files), do some analysis and writes some data files in another directory, then continues reading and writing to the end. generally my function is myfunc(int start_index,int end_index,char *read_file_directory). To improve the runtimes I created 5 threads using _beginthread each of which calls myfunc as follows:
thread 1: myfunc(1,200,read_directory)
thread 1: myfunc(201,400,read_directory)
thread 1: myfunc(401,600,read_directory)
thread 1: myfunc(6011,800,read_directory)
thread 1: myfunc(801,1000,read_directory)
myfunc works very well over 1000 files and I checked it with Visual Leak Detector 2.3, however it shows no memory leak. As soon as using multithreading, my program gives me access violation. I wrote some small functions and call them in myfunc also I am using CLAPACK (32bit release version) and fftw3f. I am totally confused, what is the reason? how I can fix it any help is appreciated.
推荐答案
这篇关于调用同一函数VS2010 _beginthread的多线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!