Configuring Server Applications for Multiprocessing

The programming model used in Windows 2000 is designed around execution threads and processes, where threads are scheduled by the operating system, not by the process that created them. If you are writing a server application in Unix, a call to fork( ) or vfork( ) creates a child process that runs independently of the parent. The same application written for Windows 2000 would probably call CreateThread to create independent processing threads. (Of course, you can continue to use multiple processes in Windows 2000. The Win32 API call CreateProcess corresponds to the standard Unix fork call to spawn a child process.) Many applications ported to Windows 2000 from Unix betray their operating system heritage and use fork instead of CreateThread. This is partially because it is a big effort to rewrite code that already works. Moreover, developers trying to maintain some degree of cross-platform compatibility with their applications are understandably reluctant to introduce platform-specific optimizations. Nevertheless, to achieve the best results on Windows 2000, programmers should adopt Windows 2000’s programming model that relies on multiple threads running within a process. Generally, wherever multiple processes are used in Unix, the Win32 programmer should use multiple threads.

Multithreaded Applications

A key advantage of threads is that they share the 4 GB virtual memory address space of the parent process (more about virtual ...

Get Windows 2000 Performance Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.