Hi,
I wrote the following code and ran the executable from two different unix terminals( to the same server).
static int p=7;
main()
{
cout << " addrs is "<<&p;//display the address of p
while(1)
{if(getchar())
p++;
cout<<" p is "<<p;
}
}
Now these 2 executables( processes) are executing the same program. On a unix system the location of variable p should be different for both the processes. however i saw that the output for both the processes displayed the same address.Also if the address is indeed same then these two processes should have interfered with each other's copy of "p", but that didn't happen either. both were executing independently of each other. Please help in understanding this.
Thanks,
Ritesh.
I wrote the following code and ran the executable from two different unix terminals( to the same server).
static int p=7;
main()
{
cout << " addrs is "<<&p;//display the address of p
while(1)
{if(getchar())
p++;
cout<<" p is "<<p;
}
}
Now these 2 executables( processes) are executing the same program. On a unix system the location of variable p should be different for both the processes. however i saw that the output for both the processes displayed the same address.Also if the address is indeed same then these two processes should have interfered with each other's copy of "p", but that didn't happen either. both were executing independently of each other. Please help in understanding this.
Thanks,
Ritesh.
Comment