I'm doing image processing. To make the computation faster, I found fork command. With fork command, I can make the computations run parallelI. The problem is the result only exists inside child process.
int main(int argc, char **argv){
int n, num, pid;
double hist[num][n];
for(i=0; i<num; i++){
if((pid = fork()) == 0){
//start computation, then save it to hist
for(j=0; j<n; j++) printf("%f ", hist[j]);
exit(0);
}
}
for(i=0; i<num; i++){
if(wait(NULL) == -1){
perror("wait");
exit(1);
}
for(j=0; j<n; j++) printf("%f ", hist[j]);
}
}
I can see the result from the first printf command. But I have nothing at second printf command. I want to know whether there is a way for parents to access child process.
If anybody know how to do it, please let me know.
Thanks anyway
susuoi
Recommended Answers
Jump to PostGoogle "mmap".
Hope this helps.
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.