In below pseudocode, can the increased value be seen by other processes or not? I am not sure which of the below scenarios is correct!
1.I know that each process has its own process address space which is located in RAM and the value of arrInP
is located in process address space of each process so when a process increments the value in some random place no other process can see it because it is done locally.
2.arrInP
is pointing to the arr
(which is shared between processes) so any modification should be done in the shared array not the local copy.
int main(){
an array "arr" has been created using mmap() and all values in it is zeor;
int i;
for(i=0;i<2;i++)
pid=fork();
if(pid==0)
run(arr);
...
}
run(char *arr){
char* arrInP=arr;
int k=//some random value;
arrInP[k]++;
}