OS/2 codes: How to emulate COPY-ON-WRITE #4 Epilogue
So far, we've researched the basic strucutre of the implementation of the copy-on-write feature. As well as, we've looked into the ways to enable copy-on-write in all threads including a main thread.
Nevertheless, this approach has some limitations. Copy-on-write will not work if
In the above first two cases, installing/uninstalling an exception handler in the context using copy-on-write manually is needed.
In case of malloc(), it may be succeeded, but it's not recommended. Failure possibility is higher.
Finally, copy-on-write not supported by Kernel is not optimal and may not be useful due to its efficiency. However, the fact itself that implementation of copy-on-write is possible is meaningful even if it is not actually useful.
Here are the codes implementing copy-on-write feature:
Nevertheless, this approach has some limitations. Copy-on-write will not work if
- it is used in a thread started by custom codes using DosCreateThread() not _beginthread()
- it is used in an alien thread created in DLLs not linked with copy-on-write module
- source memory blocks are allocated malloc() not DosAllocMem()
In the above first two cases, installing/uninstalling an exception handler in the context using copy-on-write manually is needed.
In case of malloc(), it may be succeeded, but it's not recommended. Failure possibility is higher.
Finally, copy-on-write not supported by Kernel is not optimal and may not be useful due to its efficiency. However, the fact itself that implementation of copy-on-write is possible is meaningful even if it is not actually useful.
Here are the codes implementing copy-on-write feature:
- source: https://github.com/komh/os2codes/blob/master/memory/copyonwrite.c
- header: https://github.com/komh/os2codes/blob/master/memory/copyonwrite.h
- test: https://github.com/komh/os2codes/blob/master/memory/copyonwrite-test.c
댓글
댓글 쓰기