DLLs and Tasks

One of the basic differences between an application module and a dynamic-link module is reflected in the notion of the “task.” A task is the fundamental unit of scheduling in Windows. An application module is said to be a “tasked executable” module. When an application module is loaded, a call is made to its entry point, the WinMain function, which typically contains the message loop. As the application module creates windows and begins to interact with the user, the message loop connects the application module to the Windows scheduler. As long as the user is interacting with the application's windows, messages are fed to the application module, and the module retains control of the processor.

A DLL is sometimes said to be a “nontasked executable” module. Like the application module, a dynamic-link module may contain an entry point. When it is loaded, the entry point for the library is called, but typically, it performs only minor initialization. Unlike the application module, a DLL does not interact with the Windows scheduler via a message loop; instead, the DLL waits for tasks to request its services.

Application modules are the active components of Windows. They receive system- and user-generated messages, and, when necessary, call library modules for specific data and services. Library modules exist to provide services to application modules.

NOTE :

Some DLLs are not completely passive. For example, some DLLs are device drivers for interrupt-driven devices like the keyboard, mouse, and communication ports. However, the interaction of such libraries is carefully controlled to avoid disrupting the Windows scheduler.