c++ fork() and address space -
complete gnu fork() noob here. need fork n processes exact same thing: allocate 2 arrays, initialize them , process data. tried code can simplistically compressed into:
int main() { int = 0; double b = 0; double *a1, *a2; fork(); a1 = new double[10]; a2 = new double[10]; // initialize , process data in a1 , a2 using algorithm involving , b. } is fork() in right place in terms of creating copies of a1 , a2 each process copies of a , b? or should declaration and/or initialization of a , b fall after fork() call? each process should have own a, b, a1 , a2.
address spaces of processes distinct, if in parent-child relationship.
Comments
Post a Comment