Hy,
In my current knowledge, i write the code for multiply 3x3 matrix to it self . . . Problem is that pthread_create function is not working. Here is my code
Quote:
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
int matrixA[3][3] = {{1,1,1},
{1,1,1},
{1,1,1}};
int resultA[3][3] = {0};
void *multiply(void *arg) {
int row = *((int *)(arg));
resultA[row][0] = matrixA[row][0] * matrixA[0][0]
+ matrixA[row][1] * matrixA[1][0]
+ matrixA[row][2] * matrixA[2][0];
resultA[row][1] = matrixA[row][0] * matrixA[0][1]
+ matrixA[row][1] * matrixA[1][1]
+ matrixA[row][1] * matrixA[2][1];
resultA[row][2] = matrixA[row][0] * matrixA[0][2]
+ matrixA[row][1] * matrixA[1][2]
+ matrixA[row][2] * matrixA[2][2];
return NULL;
}
int main( int argc, char *argv[] ) {
pthread_t tid[3];
printf("testing");
int i;
for( i = 0; i < 3; i++ )
{
pthread_create( &tid[0], NULL, multiply, &i);
}
int j;
for( i = 0; i < 3; i++ )
{
for( j = 0; j < 3; j++ )
{
printf("%d", resultA[i][j]);
}
printf("\n");
}
return 0;
}
Please help me to this problem ! Thanks