qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Fix vfork() syscall emulation


From: Kirill A. Shutemov
Subject: Re: [Qemu-devel] [PATCH] Fix vfork() syscall emulation
Date: Sat, 20 Sep 2008 17:20:56 +0300
User-agent: Mutt/1.5.18 (2008-05-29)

On Sat, Sep 20, 2008 at 03:52:55PM +0200, andrzej zaborowski wrote:
> 2008/9/20 Kirill A. Shutemov <address@hidden>:
> > So, implementation vfork() using pthread is wrong.
> 
> Agreed, but implementation of vfork() using fork() is wrong, too.

Why? 

man 2 vfork():

BUGS
       It  is  rather  unfortunate  that Linux revived this specter from the
       past.  The BSD man page states: "This system call will be  eliminated
       when  proper system sharing mechanisms are implemented.  Users should
       not depend on the memory sharing semantics of vfork() as it will,  in
       that case, be made synonymous to fork(2)."

If any program doesn't work with vfork() implemented using fork(). it's 
program bug.


> If
> we allow a hack, it should be commented, the second thing that needs
> to be commented is why the value of CLONE_VM flag is ignored if
> CLONE_VFORK is set -- on Linux it's not ignored.

vfork() is a hack itself. It was introduced when fork() was very expensive.
Linux fork() is implemented using copy-on-write pages, so the only penalty 
incurred by fork() is the time and memory required to duplicate the parent's
page tables. It's quite cheap. So I think emulate vfork() using fork() is 
correct.

-- 
Regards,  Kirill A. Shutemov
 + Belarus, Minsk
 + ALT Linux Team, http://www.altlinux.com/

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]