Differences between CreateProcess() in WIn32 and fork()/exec() in Unix
I need to know the difference between the two mainly when talking of address space creation of the child process. I have heard that fork() clones the address space and CreateProcess() does not. What does that mean..I request an in-depth answer.
: I need to know the difference between the two mainly when talking of address space creation of the child process. I have heard that fork() clones the address space and CreateProcess() does not. What does that mean..I request an in-depth answer.
In Windows when you call CreateProcess() it does just that. It creates a new "clean" process ready to run what you say. In Linux/Unix the fork() command first creates a whole new "copy" of the current process (creating a copy of all the memory of the program that calls fork()) so now you have two duplicate processes in memory (what a waste of time and resources). Then exec() will cause the new process to exit (thereby freeing all this memory just created for the new process) and executes the new program. I don't understand the reasoning behind Linux, their multi-tasking is so messed up from what I hear. I've been developing for Linux for a while now and I gotta say Windows is better from a developers stand-point. But it's free so you can't complain!
I'm eagerly watching the Wine (
) project take shape. It lets you run Win16/32 apps in Linux natively (no emulation). I've even submitted some of my own updates to the project. But reading from the "gurus" at work on the project it's hard to get Linux to do what Windows already can.
: In Linux/Unix the fork() command first creates a whole new "copy" of
: the current process (creating a copy of all the memory of the
: program that calls fork()) so now you have two duplicate processes
: in memory (what a waste of time and resources).
You misunderstand how the fork() function works in Linux. It doesn't actually copy all that address space, it merely clones the process's page table and sets the child process's pages to copy-on-write--so no, there is no measurable "waste of time and resources". And if you're [italic]really[/italic] that concerned about performance, you can use vfork() instead, which doesn't even bother to clone the page table. In fact, if you'd done your homework at all you would know that spawning new processes on Linux is quite significantly [italic]faster[/italic] than on Windows.
: Then exec() will cause the new process to exit (thereby freeing all
: this memory just created for the new process) and executes the new
: program. I don't understand the reasoning behind Linux, their multi-
: tasking is so messed up from what I hear.
This design (in all of POSIX-compatible operating systems, mind you, not just Linux) is because in many instances it is quite useful to do a fork without an exec--which Windows cannot do. Refer to how the Apache web server takes advantage of this feature in its multi-processing models, for instance.
I guess you heard wrong.
: I've been developing for Linux for a while now and I gotta say Windows
: is better from a developers stand-point.
Regrettably, it seems you have not been developing for Linux nearly long enough to obtain even a basic understanding of the operating system's design principles, let alone the true advantages and disadvantages of those principles.
: But reading from the "gurus" at work on the project it's hard to get
: Linux to do what Windows already can.
You might want to get a second opinion there.
It looks like you're new here. If you want to get involved, click one of these buttons!
Assembly Code Share
Getting started in assembly
C and C++
C/C++ on Linux/Unix
C/C++ Windows API
C++ Game Development
Delphi and Kylix
Java Server Pages
Access databases and VB
Advance Visual Basic
DirectX Game dev
Newbie Game Programmers
Cooling & Overclocking
Database & SQL
Sound & Music
FreeLance Software City
C# & VB.NET School Support
Join the Team
Comments on this site
New programming languages
Off topic board
Mobile & Wireless
Operating Systems & Platforms
Witsbits Go Cloud
Embedded / RTOS
Windows CE & Pocket PC
Networking And Security
Windows 2003 Server
RUP & UML
Quality & Testing
Active Server Pages
HTML & WEB-Design
Mobile Internet & Messaging
WEB-Services / SOAP
In this Discussion