Porting os.fork to Windows?

To my astonishment, I just found out this: The Windows-port of tcsh has an implementation of fork on top of the Windows API, and the license is BSD (unlike Cygwin's GPL'd fork). It would be interesting to try this with Python. Here is the source: http://tcsh.sourcearchive.com/documentation/6.14.00-7/fork_8c-source.html http://tcsh.sourcearchive.com/documentation/6.14.00-7/forkdata_8h-source.htm... Sturla Molden

On 2/17/2009 12:57 PM, Sturla Molden wrote:
http://tcsh.sourcearchive.com/documentation/6.14.00-7/fork_8c-source.html http://tcsh.sourcearchive.com/documentation/6.14.00-7/forkdata_8h-source.htm...
ftp://ftp.funet.fi/pub/unix/shells/tcsh/

Sturla Molden <sturla@...> writes:
Could you post an entry on http://bugs.python.org, so that it doesn't get lost? Thanks Antoine.

On 2/17/2009 6:02 PM, Antoine Pitrou wrote:
Could you post an entry on http://bugs.python.org, so that it doesn't get lost?
It's not a bug. If I register it as a bug, a lot of people might be annoyed. I've looked more carefully at the tcsh fork now. It requires a special version of malloc, as one must know the top and bottom of the heap. I don't think msvcr71 (or whatever version) reports that. Second, I am not sure how well it handles DLLs and memory mappings. But Cygwin's fork do, so we could get inspiration form there. S.M.

Sturla Molden schrieb:
<nit picking mode> The code implements fork() on top of the NT API, not the Win32 API. The NT Kernel supports all necessary bits and pieces for fork(). However the features aren't exposed in the Win32 API layer. According to several internet sites only the POSIX layer for NT exposes fork(). fork() is an efficient and fast op on Unix systems like Linux and BSD, because it uses a technique called copy on write (cow). I couldn't find any information if NT uses cow, too. Christian

On 2/17/2009 11:28 PM, Christian Heimes wrote:
The code implements fork() on top of the NT API, not the Win32 API.
The tcsh code implements fork on top of the Win32 API like Cygwin.
NT's fork (in the SUA subsystem on Vista) is copy-on-write optimized. It uses ZwCreateProcess in ntdll.dll to produce a copy-on-write clone of a process. But that is besides the point. The fork() in tcsh does not do copy-on-write optimization, not does Cygwin's fork(). There is nothing that mandates that fork() must be implemented with copy-on-write. The raison d'etre for pthreads was the non-cow fork() implementation in Solaris. Linux originally had a non-cow fork too. Albeit slower, this version of fork is still useful. S.M.

On 2/17/2009 12:57 PM, Sturla Molden wrote:
http://tcsh.sourcearchive.com/documentation/6.14.00-7/fork_8c-source.html http://tcsh.sourcearchive.com/documentation/6.14.00-7/forkdata_8h-source.htm...
ftp://ftp.funet.fi/pub/unix/shells/tcsh/

Sturla Molden <sturla@...> writes:
Could you post an entry on http://bugs.python.org, so that it doesn't get lost? Thanks Antoine.

On 2/17/2009 6:02 PM, Antoine Pitrou wrote:
Could you post an entry on http://bugs.python.org, so that it doesn't get lost?
It's not a bug. If I register it as a bug, a lot of people might be annoyed. I've looked more carefully at the tcsh fork now. It requires a special version of malloc, as one must know the top and bottom of the heap. I don't think msvcr71 (or whatever version) reports that. Second, I am not sure how well it handles DLLs and memory mappings. But Cygwin's fork do, so we could get inspiration form there. S.M.

Sturla Molden schrieb:
<nit picking mode> The code implements fork() on top of the NT API, not the Win32 API. The NT Kernel supports all necessary bits and pieces for fork(). However the features aren't exposed in the Win32 API layer. According to several internet sites only the POSIX layer for NT exposes fork(). fork() is an efficient and fast op on Unix systems like Linux and BSD, because it uses a technique called copy on write (cow). I couldn't find any information if NT uses cow, too. Christian

On 2/17/2009 11:28 PM, Christian Heimes wrote:
The code implements fork() on top of the NT API, not the Win32 API.
The tcsh code implements fork on top of the Win32 API like Cygwin.
NT's fork (in the SUA subsystem on Vista) is copy-on-write optimized. It uses ZwCreateProcess in ntdll.dll to produce a copy-on-write clone of a process. But that is besides the point. The fork() in tcsh does not do copy-on-write optimization, not does Cygwin's fork(). There is nothing that mandates that fork() must be implemented with copy-on-write. The raison d'etre for pthreads was the non-cow fork() implementation in Solaris. Linux originally had a non-cow fork too. Albeit slower, this version of fork is still useful. S.M.
participants (4)
-
Antoine Pitrou
-
Christian Heimes
-
Gabriel Genellina
-
Sturla Molden