To write a C program that will add elements of array using 3 child processes and a parent
darkpandawarrior last edited by
To write a C program to take input of 30 integers in an array, create three new processes,
first new process will sum the first 10 elements of array, second new process will sum next 10
elements and third will sum last 10 elements of array. Parent process will do the sum of
individual sum obtained by each child process.
avan last edited by avan
I have never done real programming in C but let's see if I can point you in the right direction. You are probably going to end up using global static variables
static int *sum_10;
So declare those outside of the main method.
Then you will probably end up using
mmapso something like
sum_10 = mmap(NULL, sizeof *sum_10, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
Then initialize each global variable somewhere in main
*sum_10 = 0;
Now you you have a set of global variables that can be shared with all processes which is the real challenge in this assignment.
Hope you figure it out. Let me know if you need more help.