Could someone please advise me on how to implement fork() in a parallel processing (multiplying) of a 2d array....I have been at this for far too long..

here is my code

for (int i = 0; i < rowCol[0]; i++ ) result[i] = (float*)malloc ( rowCol[1] * sizeof(float) );
	int i = 0;
	int j = 0;
	int k = 0;
	
	for(i = 0; i < rowCol[0]; i++) 
	{
		for( j = 0; j <rowCol[3]; j++)
		{		
			result[i][j] = 0;
			for( k = 0; k < rowCol[1]; k++)
			{
				result[i][j] += (matrix1[i][k] * matrix2[k][j]);

			}
			
		}
	}

Any step in the right direction would be greatly appreciated

Thanks

Unless its a requirement I won't use fork in this situation...I would use threads..

H there, actually it is a requirement for this assignment....out of curiosity, how would you implement with threads...

H there, actually it is a requirement for this assignment....out of curiosity, how would you implement with threads...

If your having problems with fork() then threads should probably wait. One question, how are you coordinating the calculating and passing of data between the two processes(parent and forked child)..

I am trying to use waitpid but not sure what exactly is going on.....

Here's a simple fork/pipe example that passes data from the child to the parent.

Note you'll have to scroll down a few pages to find it:

http://www.daniweb.com/forums/thread258136.html

This simple example has most of the elements that you'll need..

How many child processes do you have to create ?
In the sense, you create 1 child process, it does the computation and sends the result back
Or the more complicated scenario
Each child computes only 1 row of the result matrix and you have to create as many children as their are rows

I believe the second scenario is what I am after

Hummm ...... Are you creating 10 children simultaneously ?