Can I do a copy-on-write memcpy in Linux?

后端 未结 6 1296
面向向阳花
面向向阳花 2020-12-01 02:47

I have some code where I frequently copy a large block of memory, often after making only very small changes to it.

I have implemented a system which tracks the chan

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 03:22

    The copy-on-write mechanism employed e.g. by fork() is a feature of the MMU (Memory Management Unit), which handles the memory paging for the kernel. Accessing the MMU is a priviledged operation, i.e. cannot be done by a userspace application. I am not aware of any copy-on-write API exported to user-space, either.

    (Then again, I am not exactly a guru on the Linux API, so others might point out relevant API calls I have missed.)

    Edit: And lo, MSalters rises to the occasion. ;-)

提交回复
热议问题