freak_creeper21 wrote:
> i writen the program below but i am a noobie in multi threading. I
> need to develop a develop a multithreaded M3 program in C or C++ by
> using POSIX threads(pthreads) library to statistically analyze a set
> of data by computing its minimum value, maximum value and the mean of
> the population. any idea on how to add 8 worker threads to compute
> the minimum, maximum and mean... my data size is 8000. any idea on
> how i set the array to 0-7999. thanx for the help...
First off, this isn't exactly an ideal scenario for a multithreading
application. With only 8000 integers, you are going to spend much more
time just starting the threads than it would take to run the app. single
threaded.
This smells of homework. I can't think of a good reason to make it
multithreaded even with a huge dataset (e.g. millions of integers).
Maybe I'm just not understanding why you need to make this
multithreaded. If you still need to do this, I recommend looking at
c-prog's Links section on multithreaded applications. Plenty of
material there to keep you busy.
BTW, the way you populate the array, there is a formula* to determine
the sum and the first and last nodes are the min and max respectively.
* Karl Friedrich Gauss:
SumOfSequentialNums = NumberOfPairs * (min + max)
Where NumberOfPairs is 8000 / 2 = 4000.
No need for a for-loop at all.
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/