Device servers (like all software) needs to be designed. Some device servers are very simple and do not need an elaborate design. Others device servers are more complicated e.g. multiple processes which communicate with each other, and therefore need a more detailed design. Whatever the case is every device server needs a design.
The design can be in terms of a simple description (if the device server is simple) or it can consist of data flow diagrams and algorithms. The design should be documented in a computer readable form and this documentation stored with the device server source.
When designing a device server account should be taken of the DSM. The device server is primarily there to accept and execute commands from the network. It spends most of its time waiting for commands or clients to connect on the network and then to serve these requests. Because only one process exists per device server if the device server spends a lot of time doing something else all connections to it (and thereby all devices served by it) are blocked. In severe cases this can cause clients to timeout. Consequently the device server should not spend a lot of time executing any one command. All commands should be executed immediately so that the device server can go back to servicing the same or other clients.
Where the device server is required to treat other events which
might be time consuming or require their own polling it is
best to consider using a multi-process solution.
Time consuming commands should be relegated to independent
processes which do not block the device server.
The capabilities of the operating system should be used to communicate
between the device server and its coprocesses.
Most operating systems offer an adequate range of possibilities
for synchronising and communicating between process (for example
shared memory, events, signals fifos etc.).
Although the DSM constrains the programmer to
a single event loop within the device server it does not
prevent the device server from using the operating system to its fullest.
Refer to the section on Advanced programming techniques (later on)
and to the Device Server Notes for solutions already in
use by existing device servers.