Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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 arrInPis 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]++;
}
share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.