This document describes kernel-side implementation of requests to device drivers.
Requests from the user-side are initially handled by the driver in the context of the client user-side thread. All requests are passed to the "gateway" function: DLogicalChannelBase::Request(). This is defined as pure virtual in DLogicalChannelBase, and needs to be implemented in a derived class as part of your logical channel implementation.
There are two options for implementing this:
Use the ready-made framework provided by the DLogicalChannel class, which handles a request in the context of a single kernel-side thread. This framework uses the kernel-side messaging mechanism for queuing requests on a DFC that runs in that single kernel-side thread.
In practice, this model makes the writing of device drivers easier because the same kernel thread can be used to process requests from (potentially multiple) user-side clients and DFCs, thus in effect serialising access to the device driver, and eliminating thread-related issues, such as the need to know about mutexes, pre-emption, etc. Several drivers can use the same request/DFC kernel thread to reduce resource usage.
Derive your own logical channel class from DLogicalChannelBase to handle requests. This allows you to build your own thread model for running DFCs to handle requests and to handle request completion. This requires that you manage inter-thread conflicts. However, your design may give you the chance to do some optimisation by handling some requests in the context of the user-side thread, minimising context-switching overhead.
Option 1 lets you get a new driver up and running quickly. Option 2 gives you greater flexibility if the requirements of your driver demand it.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.