Is malloc deterministic?

后端 未结 7 1550
一整个雨季
一整个雨季 2020-12-14 07:05

Is malloc deterministic? Say If I have a forked process, that is, a replica of another process, and at some point both of them call the malloc

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-14 08:02

    You won't get the same physical address. If you have process A and B each call of malloc returns the address of a free block. The order in which A and B calls malloc is not predictable. But it never happens "in the same moment".

提交回复
热议问题