A Unix to Windows porting topic: Threads and Processes

Any Intro to Unix class teaches students about the beauty of fork() exec(), the two classic calls that allow a user to create a child process.  While creating processes on Unix systems are common, creating new processes under the win32 API is a very expensive operation.  Thus, it is always better to make your application multi-threaded to avoid process creation overhead under windows.  However, for those of you really want to know, here’s a link to msdn’s process creation sample code.

Threads are often called “light-weight” processes, each process can have one or more threads.  On Linux, the most common threading library is called the posix threads.  One of the frequently asked question is how do I port my threaded app to windows from Unix.

Well, I’ve got some good news. Pthreads has been ported to windows by the pthreads win32 project!  The licensing is even better news,  LGPL.

Even though there exists a port of pthreads for windows, the windows’ native threading API is preferred, and rather simple to use.  Here’s an example of porting a multithreaded app from Unix to Windows.   link.