copy-on-write

How can you tell if a memory page is marked as read-only?

When using copy-on-write semantics to share memory among processes, how can you test if a memory page is writable or if it is marked as read-only? Can this be done by calling a specific assembler code, or reading a certain spot in memory, or through the OS's API? ...

What is copy-on-write?

I would like to know what copy-on-write is and what it is used for? The term 'copy-on-write array' is mentioned several times in the Sun JDK tutorials but I didn't understand what it meant. ...

Why VC++ Strings are not reference counted?

STL standard do not require from std::string to be refcounted. But in fact most of C++ implementations provide refcounted, copy-on-write strings, allowing you passing string by value as a primitive type. Also these implementations (at least g++) use atomic operations making these string lock-free and thread safe. Easy test shows copy-on...

Purely functional data structures with copy-on-write?

I want to have the advantage of functional data structures (multiple versions of data that can share structure) but be able to modify it in an imperative style. What I'm thinking about (and a possible use): a RPG game in which whole game history is stored (for example, to allow for travelling back in time). Using copy-on-write, I could...

How to implement Copy-on-Write?

Hey! I want to implement a copy-on-write on my custom C++ String class, and I wonder how to... I tried to implement some options, but they all turned out very inefficient. Thank you guys :-) ...

Why is there no boost::copy_on_write_ptr?

I just saw this nice copy-on-write pointer implementation. It looks pretty generic and useful, so my question is: Is such a class contained in any of the C++ toolkits (boost, loki, etc.)? If not, I'd really like to know why because it is a really useful idiom and apparently a generic implementation seems doable (like the one I linked to)...

How to check if the block is present in a sparse file (for simple copy-on-write)?

How to get sparse block size and check if data is present at the given offset in sparse file in reiserfs/ext3 in Linux? I want to use it to implement simple copy-on-write block device using FUSE. Or I should better keep a bitmap in a separate file? ...

Why does COW mmap fail with ENOMEM on (sparse) files larger than 4GB?

This happens on a 2.6.26-2-amd64 Linux kernel when trying to mmap a 5GB file with copy-on-write semantics ( PROT_READ | PROT_WRITE and MAP_PRIVATE). Mapping files smaller than 4GB or using only PROT_READ works fine. This is not a soft resource limit issue as reported in this question; the virtual limit size is unlimited. Here is the co...