Mahol Dot Org

Icon

Weblog For All Your Need

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();
http://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 :1566

Related posts:

  1. Pipes Example Code For Linux Process Synchronizaion
  2. How To Capture X Protocol Traffic Using Wireshark On Windows XP?
  3. How To Capture X Protocol Traffic Using Wireshark On Windows XP
  4. Solution – C Requires That a Struct Or Union Has At Least One Member
  5. Unresolved External Symbol _getenv_ USE IFPORT Link Error For Application Porting From UNIX To Win32
Receive Updates By Email

Enter your email address:

Delivered by FeedBurner

Category: Linux, Unix2Win32_Porting

Tagged: , , ,

2 Responses

  1. [...] little understanding of fork basics here are few more findings on how to vfork implementation in windows operating system and fork [...]
  2. bhagwat says:
    process creation in operating system using fork statment

Leave a Reply

Lost !! Use Advanced Search

Categories

Content Protected Using Blog Protector By: PcDrome.

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