Create an exercise where a parent process makes three mmap() calls: one with MAP_PRIVATE and two with MAP_SHARED (one for an integer value, and another for a buffer). After calling fork():
the child and parent processes modify the buffers created with MAP_PRIVATE and display them (this demonstrates Copy-on-Write).
the parent and child communicate using the shared memory (one-way communication, with a busy waiting mechanism or something similar - non-optimal, for educational purposes — here, Copy-on-Write no longer applies).
the parent process increments the counter (first MAP_SHARED page) and writes a message in the buffer (second MAP_SHARED page)
the child process checks if the counter is modified (busy waiting). When it happens, the child reads the message from the buffer and displays it. If it receives the exit message written in the buffer, then the child process exits.
Create an exercise where a parent process makes three
mmap()
calls: one withMAP_PRIVATE
and two withMAP_SHARED
(one for an integer value, and another for a buffer). After callingfork()
:MAP_PRIVATE
and display them (this demonstrates Copy-on-Write).MAP_SHARED
page) and writes a message in the buffer (secondMAP_SHARED
page)