Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fork Concept in C#

Tags:

c#

.net

fork

clr

Since C# supports threading, is there any way to implement fork concept in C#?

Thanks in advance....

like image 452
Aditya Singh Avatar asked Oct 12 '10 09:10

Aditya Singh


People also ask

What does fork () do in C?

fork() in C Fork system call is used for creating a new process, which is called child process, which runs concurrently with the process that makes the fork() call (parent process). After a new child process is created, both processes will execute the next instruction following the fork() system call.

What is fork () and why is it used?

fork() is how you create new processes in Unix. When you call fork , you're creating a copy of your own process that has its own address space. This allows multiple tasks to run independently of one another as though they each had the full memory of the machine to themselves.

Where is fork defined C?

fork() system call is used to create child processes in a C program. fork() is used where parallel processing is required in your application. The fork() system function is defined in the headers sys/types. h and unistd.

What library is fork () in C?

The C library defines fork() . It is the UNIX/Linux-specific system calls to create a process, on linux etc.


1 Answers

This is more a matter of .NET / CLR than of C#. Generally, it's a matter of the underlying operating system. Windows do not support fork()-like semantics of spawning new processes. Also, fork() has nothing to do with multithreading support.

The semantics of fork() involves duplicating the contents of the original process's address space. My opinion is this is an obsolete approach to process creation and has barely any room in the Windows world, because it involves a lot of security and operating system architecture concerns.

From the .NET point of view, the fundamental problem with fork() would be the approach to duplicating and/or sharing unmanaged resources (file handles, synchronization objects, window handles (!), etc.) between the old and the new process. I think there is no serious reason to introduce such concept either to .NET or to the underlying Windows operating system.

For further discussion see saurabh's link.

like image 163
Ondrej Tucny Avatar answered Oct 01 '22 15:10

Ondrej Tucny