Skip to content
Snippets Groups Projects
Commit 73015b9f authored by Marc Feger's avatar Marc Feger
Browse files

Some changes

parent 8833be74
No related branches found
No related tags found
No related merge requests found
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "matrix.h"
#define DIMENSION 1000
int main(void){
pid_t piet= fork();
if(piet == (pid_t)0){
// child
printf("Child starts...\n");
long long *matrixA = (long long*)malloc(DIMENSION * DIMENSION * sizeof(long long));
long long *matrixB = (long long*)malloc(DIMENSION * DIMENSION * sizeof(long long));
long long *matrixC = (long long*)malloc(DIMENSION * DIMENSION * sizeof(long long));
srand (time( NULL));
initializeMatrix(matrixA, DIMENSION, DIMENSION);
initializeMatrix(matrixB, DIMENSION, DIMENSION);
multiplyMatrices(matrixA, matrixB, matrixC, DIMENSION, DIMENSION, DIMENSION);
free(matrixA);
free(matrixB);
free(matrixC);
printf("Child finish...\n");
}else{
// parent
int status = -1;
int seconds = 0;
while(status == -1){
waitpid(piet, &status, WNOHANG);
printf("Parent waits since: %d\n", seconds++);
sleep(1);
}
}
return 0;
}
File added
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment