In general, services may be provided to client programs in two ways:
by a conventional library or DLL
by a server
A conventional library has the advantages that the technology is familiar and universal, and that transfer of control from client to service provider is very fast — a few machine instructions.
However, it is appropriate to provide services through a server:
when the services involve management of one or more shared system resources.
For example, the File Server manages all files and file systems on behalf of all client programs. The file server may therefore ensure that all file resources are correctly shared. Similarly, the Window Server allows all applications to share the machine’s screen, keyboard, and pointer devices.
when a degree of isolation is required between client and server.
Since client and server run in separate threads, they may also run in separate processes, with separate address spaces. This means there is no possibility of communication between them except by the interface provided by the server and its client interface. Thus, misbehaved clients cannot corrupt the server or any of the resources it manages on behalf of other clients.
The File Server architecture is strongly motivated by this requirement.
when asynchronous services are required.
Asynchronous requests can be handled using Kernel services (e.g. timers) and active objects within an application thread. However, when the completion of a request is some time in the future, and the application program making the request might no longer be present, a continuously-running server is appropriate. The best example of this is the Alarm Server.
Most servers are motivated by a combination of requirements such as these.
There are three distinct aspects to the service provided by a server:
a server program, which runs in its own thread
several client programs, each running in their own thread
a client interface, provided by the server, for use by each client program