gpt4 book ai didi

c - 不共享相同数据的并行进程

转载 作者:太空宇宙 更新时间:2023-11-04 05:23:20 24 4
gpt4 key购买 nike

<分区>

我正在编写一些 C 代码,其中存在一个作为 int 指针的变量。进程应该做的是减去该变量的值,直到它达到 0。问题是即使程序打印的地址相同,每个进程似乎都有自己的变量副本。发生这种情况是因为每个进程在内存中都有自己的空间吗?

这是输出:

START
Account address: 0x7ffee5820be0
Parent substracted 10. Account value: 90, address 0x7ffee5820be0
Parent substracted 10. Account value: 80, address 0x7ffee5820be0
Parent substracted 10. Account value: 70, address 0x7ffee5820be0
Parent substracted 10. Account value: 60, address 0x7ffee5820be0
Parent substracted 10. Account value: 50, address 0x7ffee5820be0
Parent substracted 10. Account value: 40, address 0x7ffee5820be0
Parent substracted 10. Account value: 30, address 0x7ffee5820be0
Parent substracted 10. Account value: 20, address 0x7ffee5820be0
Parent substracted 10. Account value: 10, address 0x7ffee5820be0
Parent substracted 10. Account value: 0, address 0x7ffee5820be0
Child substracted 10. Account value: 90 , address 0x7ffee5820be0
Child substracted 10. Account value: 80 , address 0x7ffee5820be0
Child substracted 10. Account value: 70 , address 0x7ffee5820be0
Child substracted 10. Account value: 60 , address 0x7ffee5820be0
Child substracted 10. Account value: 50 , address 0x7ffee5820be0
Child substracted 10. Account value: 40 , address 0x7ffee5820be0
Child substracted 10. Account value: 30 , address 0x7ffee5820be0
Child substracted 10. Account value: 20 , address 0x7ffee5820be0
Child substracted 10. Account value: 10 , address 0x7ffee5820be0
Child substracted 10. Account value: 0 , address 0x7ffee5820be0

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com