Discussion Overview
The discussion revolves around the use of malloc and mmap'ed shared memory for efficient data sharing between parent and child processes in a C/C++ programming context. Participants explore various methods and considerations for implementing shared memory to avoid page faults, particularly in scenarios involving multiple child processes and memory allocation.
Discussion Character
- Exploratory
- Technical explanation
- Debate/contested
Main Points Raised
- One participant proposes using mmap'ed shared memory to set the area from which malloc allocates memory, arguing it would facilitate data sharing without page faults.
- Another participant mentions that in GNU Linux, malloc hooks can be installed, but notes that this approach is not portable across different operating systems.
- A participant suggests that in Windows, shared memory files can be utilized, but raises concerns about the complexity of using Windows-specific debugging functions and synchronization mechanisms.
- One participant expresses reluctance to implement a full heap allocator using glibc malloc hooks, citing a lack of expertise and previous unsuccessful attempts to redefine memory allocation functions.
- Another participant critiques the original proposal, suggesting that if child processes do not require dynamic memory allocation, using threads might be a more efficient alternative.
- A participant elaborates on the prime number checking program, explaining the inefficiencies caused by page copying when the parent writes back results, and reiterates the desire to use mmap for shared memory to mitigate this issue.
- Another participant questions the viability of using threads instead of processes, highlighting the benefits of a common virtual address space and the potential for reduced overhead.
Areas of Agreement / Disagreement
Participants express differing views on the best approach to achieve efficient data sharing between parent and child processes. There is no consensus on whether to use malloc with mmap, shared memory files, or to switch to a threading model.
Contextual Notes
Some participants note limitations in their proposed solutions, such as the non-portability of certain methods and the complexity of implementing synchronization in Windows. Additionally, there are unresolved questions about the implications of using threads versus processes in the context of the specific application discussed.