I recently read the popular post about Redis architecture. It had a chapter about forking - the process of how they create a disk backup of the in-memory database contents. The chapter addresses some same system programming topics as the linux-insides book I've been glancing over recently.
As the article points out, the POSIX fork system call creates a duplicate of the calling process but does not copy the memory pages. If the parent or any child process access a memory page, it points to the read-only shared memory until the process changes any values of that page. The calling process then gets a writable copy of the accessed memory pages (copy-on-write).
DALL·E 2 did not know how to draw a go gopher but close enough! |
As a curiosity, a go program can be forked but works only in trivial cases. I'm unsure what happens under the hood, TBH but seems to work as expected. Here is an example gist.
Comments
Post a Comment