PDA

View Full Version : Unix fork & win32 thread system call....whats the difference?



Blue_face
04-06-2004, 09:30 PM
Hi...
Can someone explain to me what is the difference between the UNIX fork system call and the Win32 CreateThread system call.

Thank you. :)

bmason
05-06-2004, 01:56 PM
In unix fork() creates an exact duplicate of the process that called it. The new process is completely separate to the origional, the only difference is the value returned by the fork() function in the two copies which is used to distinguish between the parent and the child process.
If you want to share data between processes you have to set something up yourself.

I'm not too familiar with win32, but in general, threads all share the chunk of memory. So they are faster to create because you don't have to duplicate everything, but there are more concurrency issues because they are all working with the same variables etc.

Google will find you better explanations. fork() is very well documented. Try a search for "The UNIX Time-Sharing System" which is the paper by the creators of unix that first described how it works.