Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GDB: Does "catch vfork" work?



On Oct 8, 2005, at 6:55 AM, Damien Bobillot wrote:

If you use fork, the whole parent memory is copied.

There is no reason the kernel could't (or doesn't) use copy on write semantics for fork, AFAIK. Whether or not it actually does it is another question.


If you use vfork, the memory is lazily copied : the system wait until it really need to make the copy, ie if both processes don't write anything in a given memory page, the system won't make the copy, but if one do write something, the system make the copy just before effectively writing things. This use the copy-on-write flag of the paged memory manager.

The only difference between fork and vfork is that vfork is more efficient : for the developer, even when debugging, both functions seem to work the same way.

Again, I'm not a complete expert on the topic, but my understanding is that vfork does not use copy on write semantics, but rather shares the parent's address space until the exec. If you do anything after the fork and before the exec you are making changes in the parent's address space (and they are probably unexpected changes from the parent's POV.) My experience is consistent with this. (In other words, I believe the man page to be correct.)


Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden
References: 
 >GDB: Does "catch vfork" work? (From: Daniel Jalkut <email@hidden>)
 >Re: GDB: Does "catch vfork" work? (From: Damien Bobillot <email@hidden>)
 >Re: GDB: Does "catch vfork" work? (From: Daniel Jalkut <email@hidden>)
 >Re: GDB: Does "catch vfork" work? (From: Damien Bobillot <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.