I do not know if this is the cause of your problem, but:
pthread_create(&p[j],NULL,mult_thread,&j);
definitely broken. You go to j &j . Therefore, each thread receives a random value 0 <= start_row <= 9 when it really starts. It's probably best to just go to (void*)j and get it with (int)j .
You also never initialize res_mat , but in any case it will be initialized.
EDIT: The reason the starting_row value is random is because j goes through all the numbers between 0 and 9 between the running thread and connects. Thus, the thread will be launched at some random point between the two, and at that moment the value j will be obtained.
source share