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

Edited 6 Years Ago by Nick Evan: Fixed tags

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.....

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

This article has been dead for over six months. Start a new discussion instead.