【发布时间】:2013-08-08 07:30:11
【问题描述】:
创建了两个进程。
他们每个人都使用输入0调用函数A(函数A在其他一些.c文件中)。
变量 x 需要是全局变量,但是对于每个进程来说它应该是私有的。
既然是x = y,似乎每个进程都有自己的x。我想知道为什么?为什么 z 在两个进程之间共享?
int x;
int z;
void A(int y)
{
x = y;
x++;
z++;
B();
}
void B()
{
x--;
}
在 main.c 中
//2 process created and each of them call A(0)
【问题讨论】:
-
你是在 main 中创建两个线程吗?
-
2个进程,是在main
标签: c process static mutex private