Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Consider process P that owns 10 physical frames. Suppose process P calls fork() and creates a child process Q.

How many physical frames does the child initially own, without copy-on-write? 10

How many frames does the child initially own, with copy-on-write? 0 not sure if this is a correct answer.

Thank you!

share|improve this question

1 Answer 1

The forked process needs act as if it was an exact image of the parent, so without COW it would indeed own 10 frames initially.

But it can't initially own no memory of its own at all - at least one non-shared frame is necessary: fork doesn't return the same value in the parent and the child, so the page where that return value is stored cannot be shared.

In practice, there will probably be a few pages that aren't shared, the exact number will probably depend on the operating system. The only certain thing is that it can't be zero.

share|improve this answer
    
Where can I find more info on on how many frames frames child will get with COW? Thank you! –  SoftDisk - Dec 29 '12 at 17:34
    
I don't think you will (easily anyway) except if you focus on one very specific OS & kernel version, and dig into the guts of it. I don't really see why the exact number is important, that's a really low-level implementation detail you won't get guarantees about (except possibly on things like hard-real-time OSes or such specialized things). –  Mat Dec 29 '12 at 17:37
    
It was a question on the final exam. The teacher said that with COW is 0. I am just not sure. Thanks. –  SoftDisk - Dec 29 '12 at 19:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.