CreateProcess And fork() In Windows Differences And Implementation

Although there is a one-to-one mapping between C UNIX APIs and Win32 APIs for most of the APIs like open to CreateFile, read to ReadFile, write to WriteFile, ioctl to DeviceIOControl, close to CloseFile, and so on. Still, While Porting applications from UNIX to Win32 natively,
One of the largest areas of difference is in the process model. UNIX has fork; Win32 does not. Depending on the use of fork and the code base, Win32 has two APIs that can be used: CreateProcess and CreateThread. A UNIX application that forks multiple copies of itself can be reworked in Win32 to have either multiple processes or a single process with multiple threads read Porting from UNIX to Win32 for further study.

What’s the best way to duplicate fork() in windows?
Forking a Win32 Process

Process Creation in cygwin
The fork call in Cygwin is particularly interesting because it does not map well on top of the Win32 API. This makes it very difficult to implement correctly. Currently, the Cygwin fork is a non-copy-on-write implementation similar to what was present in early flavors of UNIX.  The first thing that happens when a parent process forks a child process is that the parent initializes a space in the Cygwin process table for the child. It then creates a suspended child process using the Win32 CreateProcess call.

Read further to know why process creation in cygwin is slow? windows fork process; dynamic forking process win32

Here are Some Differences between CreateProcess() in WIn32 and fork()/exec();
https://i2.wp.com/users.telenet.be/bartl/classicperl/fork/c_code.gifUnix has two primitives: fork (create new process identical to calling process) and exec (replace details of current process with those loaded from executable file).
Fork also copies open file descriptors, including network sockets (like filehandles) are inherited by children.
Windows has one primitive: CreateProcess, which is roughly equivalent to fork-then-exec.

Number of View :5288

Tags: , , ,

  1. #1 written by bhagwat September 29th, 2010 at 01:56

    process creation in operating system using fork statment

    RE Q

SetPageWidth
Content Protected Using Blog Protector By: PcDrome.

Mahol Dot Org is Stephen Fry proof thanks to caching by WP Super Cache