pls help.. i have spent 1½ day on this stupid problem. im pretty sure the solution is pretty simple but im new in c
I have modified the code and removes all the unnesserary code with "....." so its easier to spot my mistake
Im creating 100 threads
I have to create 2 processors which take care of these threads, but its no working. The only thread which is working is the first thread
the first and the secound thread prints out the right message ( they are the one which creates the processors as well), but i wanted the 3, 4... 100 thread threads to print out the right message as well.. but its not working.. pls helpCode:
int main(int argc, char *argv[])
........
res = pthread_create(&patientThread, NULL, (void *)&skrenke, (void *)&p[antal]);
......
}
void skrenke(void *ID)
{
............
int mod = nr%2 //each processor should take every secound thread eg. if its nr 1, processor 1 has to take care of it, and if its nr 2 processor 2 has to take care of it
if(nr==0) // nr=0 is the first thread which create the 1st processor
{
pid = fork();
}
if(pid==0 && mod==0)
{
printf("\nthe first processor is taking care of this thread\n");
}
if(nr==1) // nr=01 is the secound thread which creates the 2nd processor
{
pid1 = fork();
}
if (pid1==0 && mod ==1)
{
printf("the secound processor is taking care of thread 1 and every secound thread
}
};
