本文介绍了请帮助...平行执行.时间比顺序的要多.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在c#.net 4.0中为我的并行性项目编写代码.
编码后,我遇到了一个并行执行程序的问题.时间比顺序的要多.

``x''和``y''是全局数组变量.

I am coding in c#.net 4.0 for my project on parallelism.
After coding I came across a problem that parallel exec. time is coming more than sequential one.

''x'' and ''y'' are global arrays variables.

	Program object1= new Program();
	Program object2= new Program();

/****SEQUENTIAL*****/
	object1.func1(x);
	object1.func2(x);
	object1.func3(x);
	object1.func4(x);

	object2.func1(y);
	object2.func2(y);
	object2.func3(y);
	object2.func4(y);
/****SEQUENTIAL*****/

/****PARALLEL******/
            Parallel.Invoke(
                () =>
                {
	object1.func1(x);
	object1.func2(x);
	object1.func3(x);
	object1.func4(x);
                },
                () =>
                {
	object2.func1(y);
	object2.func2(y);
	object2.func3(y);
	object2.func4(y);
                });
/****PARALLEL******/



问题可能是错误共享,但是如果使用了对象的变量的两个不同副本,那么应该不会有错误共享的问题.我不知道到底是什么问题.请帮忙.



The problem may be of false sharing, but I if two different copies of variables through objects are being used, then there should not be a problem of false sharing..! I don''t know exactly what is the problem actually. Please help.

推荐答案


这篇关于请帮助...平行执行.时间比顺序的要多.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 13:32