|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-FD8634B8-E522-4AC4-8129-ED807A7754A2-GENID-1-2-1-9-1-5-1-6-1" xml:lang="en"><title>Kernel-side |
|
13 Implementation</title><shortdesc>This document describes kernel-side implementation of requests |
|
14 to device drivers.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
15 <p>Requests from the user-side are initially handled by the driver |
|
16 in the context of the client user-side thread. All requests are passed to |
|
17 the "gateway" function: <xref href="GUID-E7550422-5121-3393-A85E-BB797969CD2A.dita#GUID-E7550422-5121-3393-A85E-BB797969CD2A/GUID-FD4DA73F-45E7-37BE-9380-1D8ED36114F7"><apiname>DLogicalChannelBase::Request()</apiname></xref>. |
|
18 This is defined as pure virtual in <codeph>DLogicalChannelBase</codeph>, and |
|
19 needs to be implemented in a derived class as part of your logical channel |
|
20 implementation. </p> |
|
21 <fig id="GUID-0DEEF003-53B6-5892-8FF2-6684BC424E27-GENID-1-2-1-9-1-5-1-6-1-3-2"> |
|
22 <title> Device driver logical channel communication |
|
23 </title> |
|
24 <image href="GUID-4A2E212E-BC1B-5965-9A62-6309CC7CAAAB_d0e61647_href.png" placement="inline"/> |
|
25 </fig> |
|
26 <p>There are two options for implementing this: </p> |
|
27 <ol id="GUID-F9FDC221-82F8-569E-B12A-969194137E24-GENID-1-2-1-9-1-5-1-6-1-3-4"> |
|
28 <li id="GUID-A58B2511-6058-5DE6-8407-0ED4EB7A0112-GENID-1-2-1-9-1-5-1-6-1-3-4-1"><p>Use the ready-made framework |
|
29 provided by the <xref href="GUID-A3CC1D95-4681-3349-A67C-F113A614041D.dita"><apiname>DLogicalChannel</apiname></xref> class, which handles a |
|
30 request in the context of a single kernel-side thread. This framework uses |
|
31 the kernel-side messaging mechanism for queuing requests on a DFC that runs |
|
32 in that single kernel-side thread. </p> <p>In practice, this model makes the |
|
33 writing of device drivers easier because the same kernel thread can be used |
|
34 to process requests from (potentially multiple) user-side clients and DFCs, |
|
35 thus in effect serialising access to the device driver, and eliminating thread-related |
|
36 issues, such as the need to know about mutexes, pre-emption, etc. Several |
|
37 drivers can use the same request/DFC kernel thread to reduce resource usage. </p> </li> |
|
38 <li id="GUID-DE277962-5BDC-5CD7-9868-65FA576E11AD-GENID-1-2-1-9-1-5-1-6-1-3-4-2"><p>Derive your own logical |
|
39 channel class from <xref href="GUID-E7550422-5121-3393-A85E-BB797969CD2A.dita"><apiname>DLogicalChannelBase</apiname></xref> to handle requests. |
|
40 This allows you to build your own thread model for running DFCs to handle |
|
41 requests and to handle request completion. This requires that you manage inter-thread |
|
42 conflicts. However, your design may give you the chance to do some optimisation |
|
43 by handling some requests in the context of the user-side thread, minimising |
|
44 context-switching overhead. </p> </li> |
|
45 </ol> |
|
46 <p>Option 1 lets you get a new driver up and running quickly. Option 2 gives |
|
47 you greater flexibility if the requirements of your driver demand it. </p> |
|
48 </conbody></concept> |