Click here to Skip to main content
15,922,696 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: which is better and why??? Pin
Laxman Auti19-Jun-06 22:21
Laxman Auti19-Jun-06 22:21 
AnswerRe: which is better and why??? [modified] Pin
Viorel.19-Jun-06 22:22
Viorel.19-Jun-06 22:22 
GeneralRe: which is better and why??? Pin
namaskaaram19-Jun-06 22:28
namaskaaram19-Jun-06 22:28 
GeneralRe: which is better and why??? Pin
Jörgen Sigvardsson19-Jun-06 23:44
Jörgen Sigvardsson19-Jun-06 23:44 
AnswerRe: which is better and why??? Pin
toxcct19-Jun-06 22:37
toxcct19-Jun-06 22:37 
GeneralRe: which is better and why??? Pin
Kevin McFarlane19-Jun-06 22:44
Kevin McFarlane19-Jun-06 22:44 
AnswerRe: which is better and why??? Pin
Jörgen Sigvardsson19-Jun-06 23:43
Jörgen Sigvardsson19-Jun-06 23:43 
QuestionMultithreading question - measure time, and block code Pin
uusheikh19-Jun-06 22:07
uusheikh19-Jun-06 22:07 
Hi,

lets say that i have an operation that is performed on two sets of data independently,
that is the data is separable, and not related.

so, for an example;
<br />
void Function1(int *a, int *b, int *c, int count)<br />
{<br />
	for(int i=0; i< count; i++)<br />
		c[i] = a[i] * b[i];<br />
}<br />

I can measure the execution time using QueryPerformanceCounter.
<br />
main()<br />
{<br />
	//QueryPerformanceCounter - start<br />
	Function1(a,b,c,count);<br />
	///QueryPerformanceCounter - end<br />
<br />
	OtherFunction(...);<br />
}


My question is, now, if i want to break the function to two threads, to take advantage
of dual cpu, or dual core, how do i

1- Measure the performance of the code..
2- Determine the function has finished, or terminated


Example of an implementation that i am looking at is;

void Function2(int *a, int *b, int *c, int count)<br />
{<br />
	AfxBeginThread1()// for data in the range of 0 -> count/2, handled by this thread<br />
	AfxBeginThread2()// for data in the range of count/2 -> count<br />
}

<br />
main()<br />
{<br />
	Function2(a,b,c,count);<br />
	// How to measure the time Function2 takes? Function2 is multithreaded.<br />
	// Time it takes for both thread to finish, <br />
<br />
<br />
	// How do i block OtherFunction from executing before Function2 finishes,<br />
	// that means both threads started from Function2 have finished??<br />
<br />
	OtherFunction(...);<br />
}


Can anyone help on this?

Thanks
AnswerRe: Multithreading question - measure time, and block code Pin
Hamid_RT19-Jun-06 22:12
Hamid_RT19-Jun-06 22:12 
GeneralRe: Multithreading question - measure time, and block code Pin
uusheikh19-Jun-06 22:22
uusheikh19-Jun-06 22:22 
AnswerRe: Multithreading question - measure time, and block code [modified] Pin
Eytukan19-Jun-06 23:04
Eytukan19-Jun-06 23:04 
AnswerRe: Multithreading question - measure time, and block code Pin
Eytukan19-Jun-06 23:17
Eytukan19-Jun-06 23:17 
GeneralRe: Multithreading question - measure time, and block code Pin
uusheikh19-Jun-06 23:31
uusheikh19-Jun-06 23:31 
QuestionEnable edit control in Dialog access Enter and ESC Pin
zeus_master19-Jun-06 22:04
zeus_master19-Jun-06 22:04 
AnswerRe: Enable edit control in Dialog access Enter and ESC Pin
Hamid_RT19-Jun-06 22:09
Hamid_RT19-Jun-06 22:09 
QuestionRe: Enable edit control in Dialog access Enter and ESC Pin
zeus_master19-Jun-06 22:15
zeus_master19-Jun-06 22:15 
AnswerRe: Enable edit control in Dialog access Enter and ESC Pin
FarPointer19-Jun-06 22:10
FarPointer19-Jun-06 22:10 
AnswerRe: Enable edit control in Dialog access Enter and ESC Pin
Cedric Moonen19-Jun-06 22:12
Cedric Moonen19-Jun-06 22:12 
QuestionRe: Enable edit control in Dialog access Enter and ESC Pin
zeus_master19-Jun-06 23:00
zeus_master19-Jun-06 23:00 
AnswerRe: Enable edit control in Dialog access Enter and ESC Pin
Cedric Moonen19-Jun-06 23:08
Cedric Moonen19-Jun-06 23:08 
GeneralRe: Enable edit control in Dialog access Enter and ESC Pin
zeus_master19-Jun-06 23:39
zeus_master19-Jun-06 23:39 
GeneralRe: Enable edit control in Dialog access Enter and ESC Pin
Cedric Moonen19-Jun-06 23:47
Cedric Moonen19-Jun-06 23:47 
GeneralRe: Enable edit control in Dialog access Enter and ESC Pin
zeus_master20-Jun-06 1:54
zeus_master20-Jun-06 1:54 
AnswerRe: Enable edit control in Dialog access Enter and ESC [modified] Pin
Weiye Chen19-Jun-06 22:25
Weiye Chen19-Jun-06 22:25 
GeneralRe: Enable edit control in Dialog access Enter and ESC [modified] Pin
zeus_master19-Jun-06 22:31
zeus_master19-Jun-06 22:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.