[This is perhaps OT on the Cython list. Please forgive me the noise.]

Stefan,

CreateProcess in Win32 API and fork in Interix (SUA/SFU) both call the
kernel function ZwCreateProcess in ntdll.dll. If NULL is passed as section
handle to ZwCreateProcess, it will clone the current process. The
copy-on-write optimization actually happen in hardware. Most modern
processors have a paging memory-management unit that can tag pages as
shared and copy-on-write. The reason that early versions of Unix or Linux
did not copy-on-write optimize fork but modern do, is that CPUs have
evolved. You can read about Windows kernel programming in Nebbet's book on
NT kernel internals. It even has example code for a boiler-plate
implementation of fork.

Cygwin's problem is that hooking up a process created by ZwCreateProcess
to the Win32 or SUA subsystem is undocumented; neither MS documentation or
Nebbet cover that. That is why Cygwin does not implement a copy-on-write
fork yet, although most modern hardware supports it.

I recommend using Interix (SFU/SUA) instead of Cygwin. You will need 
Windows XP professional or enterprice, or Windows Vista / Windows 7
Ultimate. The codebase of Interix is mostly derived from OpenBSD. This
means it is very safe. The old POSIX subsystem form Windows NT4 is
deprecated in favour of Interix. You'll find more information at
www.interix.com. Prebuilt binaries for common Unix tools can be downloaded
from the Warehouse in SUA community.

Note that SUA is UNIX, not Windows, it just happens to share kernel. This
means the Windows API cannot be used; processes do not run on the Win32
subsystem. For graphics you e.g. need to run an X-server on Win32, and
good X-servers for Windows tend to be expensive.

With modern CPUs that hardware accelerate virtualization (AMD-V or Intel
VT-X), I prefer to use virtualization software instead of Interix or
Cygwin. My current favourite is Sun Microsystems' VirtualBox, which is
free for personal use. Note that the free license for VirtualBox also
allow commercial use in an organization; what is not covered is automated
deployment on multiple computers. Even without HW accelerated
virtualization, VirtualBox or VMware Workstation/Server can be quite
efficient. On my Windows 7 desktop computer I run Mandriva Linux 2010 in
VirtualBox. (I have also tested Ubuntu and OpenSolaris.) With
virtualization, we also avoid having to buy an expensive X-server for
Windows. And most software are easier to build and better tested on a
modern Linux than Interix.

Sturla





Stefan Behnel wrote:
> Sturla Molden, 31.12.2009 10:39:
>> If you need full Unix compatibility, you should use SFU (add-on to Win
>> XP) or SUA (Vista and Win7 Ultimate), which gives you a certified UNIX
>> on top of the NT-kernel (Interix).
>
> Interesting, that's the first time I hear about these (although I knew that
> NT always had a POSIX-like kernel personality). I found a couple of your
> posts to the python MLs that seem to suggest that they even have an
> efficient copy-on-write fork implementation. That (alongside with some
> other performance issues) is the main drawback of cygwin, IMHO. Do you have
> any references that back this claim? I couldn't find anything on a quick
> web search.
>
> Stefan
>
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev


_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to