author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 14 May 2010 17:13:29 +0300 | |
changeset 109 | b3a1d9898418 |
parent 102 | ef2a444a7410 |
child 152 | 657f875b013e |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// |
|
15 |
||
16 |
/** |
|
17 |
@file |
|
18 |
@internalComponent |
|
19 |
*/ |
|
20 |
||
21 |
#ifndef MPAGER_H |
|
22 |
#define MPAGER_H |
|
23 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
24 |
#include "mmu.h" |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
25 |
#include <kern_priv.h> |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
26 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
27 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
28 |
Maximum number of pages to attempt to clean in one go. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
29 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
30 |
const TInt KMaxPagesToClean = 4; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
31 |
|
0 | 32 |
struct SVMCacheInfo; |
33 |
class DMemModelThread; |
|
34 |
class DMemoryMappingBase; |
|
35 |
||
36 |
class DPager |
|
37 |
{ |
|
38 |
public: |
|
39 |
DPager(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
40 |
void InitCache(); |
0 | 41 |
void Init3(); |
42 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
43 |
FORCE_INLINE TBool CacheInitialised() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
44 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
45 |
return iYoungOldRatio && iMinimumPageLimit; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
46 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
47 |
|
0 | 48 |
FORCE_INLINE TUint NumberOfFreePages() |
49 |
{ |
|
50 |
return iNumberOfFreePages; |
|
51 |
} |
|
52 |
||
53 |
FORCE_INLINE TUint NumberOfDirtyPages() |
|
54 |
{ |
|
55 |
TUint ret; |
|
56 |
MmuLock::Lock(); |
|
57 |
ret = iNumberOfDirtyPages; |
|
58 |
MmuLock::Unlock(); |
|
59 |
return ret; |
|
60 |
} |
|
102
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
61 |
|
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
62 |
FORCE_INLINE TUint MinimumPageCount() |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
63 |
{ |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
64 |
return iMinimumPageCount; |
ef2a444a7410
Revision: 201018
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
90
diff
changeset
|
65 |
} |
0 | 66 |
|
67 |
FORCE_INLINE void SetWritable(SPageInfo& aPageInfo) |
|
68 |
{ |
|
69 |
if (!aPageInfo.IsDirty()) |
|
70 |
{// This is the first mapping to write to the page so increase the |
|
71 |
// dirty page count. |
|
72 |
iNumberOfDirtyPages++; |
|
73 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
74 |
aPageInfo.SetWritable(); |
0 | 75 |
} |
76 |
||
77 |
FORCE_INLINE void SetClean(SPageInfo& aPageInfo) |
|
78 |
{ |
|
79 |
__NK_ASSERT_DEBUG(iNumberOfDirtyPages); |
|
80 |
__NK_ASSERT_DEBUG(aPageInfo.IsDirty()); |
|
81 |
aPageInfo.SetClean(); |
|
82 |
iNumberOfDirtyPages--; |
|
83 |
} |
|
84 |
||
85 |
/** |
|
86 |
Remove RAM pages from the cache and return them to the system's free pool. |
|
87 |
(Free them.) |
|
88 |
||
89 |
This is called by class Mmu when it requires more free RAM to meet an |
|
90 |
allocation request. |
|
91 |
||
92 |
@param aNumPages The number of pages to free up. |
|
93 |
@return True if all pages could be freed, false otherwise |
|
94 |
@pre RamAlloc mutex held. |
|
95 |
*/ |
|
96 |
TBool GetFreePages(TInt aNumPages); |
|
97 |
||
98 |
||
99 |
/** |
|
100 |
Attempts to rejuvenate or page in the page to the mapping that took the page fault. |
|
101 |
||
102 |
@param aPc Address of instruction causing the fault. |
|
103 |
@param aFaultAddress Address of memory access which faulted. |
|
104 |
@param aFaultAsid The asid of the faulting thread's process. |
|
105 |
@param aAccessPermissions Bitmask of values from enum TAccessPermissions, which |
|
106 |
indicates the permissions required by faulting memory access. |
|
107 |
@param aMapInstanceCount The instance count of the mapping when it took the page fault. |
|
108 |
@param aThread The thread that took the page fault. |
|
109 |
@param aExceptionInfo The processor specific exception info. |
|
110 |
||
111 |
@return KErrNone if the page is now accessable, otherwise one of the system wide error codes. |
|
112 |
*/ |
|
113 |
TInt HandlePageFault( TLinAddr aPc, TLinAddr aFaultAddress, TUint aFaultAsid, TUint aFaultIndex, |
|
114 |
TUint aAccessPermissions, DMemoryObject* aMemory, DMemoryMapping* aMapping, |
|
115 |
TUint aMapInstanceCount, DThread* aThread, TAny* aExceptionInfo); |
|
116 |
||
117 |
||
118 |
/** |
|
119 |
Fault enumeration |
|
120 |
*/ |
|
121 |
enum TFault |
|
122 |
{ |
|
123 |
}; |
|
124 |
||
125 |
/** |
|
126 |
Fault the system. |
|
127 |
*/ |
|
128 |
static void Fault(TFault aFault); |
|
129 |
||
130 |
/** |
|
131 |
Get state of live page list. |
|
132 |
*/ |
|
133 |
void GetLiveListInfo(SVMCacheInfo& aInfo); |
|
134 |
||
135 |
/** |
|
136 |
Resize the live page list. |
|
137 |
*/ |
|
138 |
TInt ResizeLiveList(TUint aMinimumPageCount, TUint aMaximumPageCount); |
|
139 |
||
140 |
/** |
|
141 |
Recalculate live list size. |
|
142 |
*/ |
|
143 |
TInt ResizeLiveList(); |
|
144 |
||
145 |
/** |
|
146 |
Flush (unmap) all memory which is demand paged. |
|
147 |
This reduces the live page list to a minimum. |
|
148 |
*/ |
|
149 |
void FlushAll(); |
|
150 |
||
151 |
/** |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
152 |
Flush demand paged pages in a specified region. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
153 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
154 |
The memory must reside in a single memory object. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
155 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
156 |
@param aProcess The process containing the pages to flush. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
157 |
@param aStart The start address of the region. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
158 |
@param aSize The size of the region in bytes. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
159 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
160 |
@return KErrBadDescriptor If the memory region is invalid or spans more than one memory object, |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
161 |
otherwise KErrNone. |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
162 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
163 |
TInt FlushRegion(DMemModelProcess* aProcess, TLinAddr aStartAddress, TUint aSize); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
164 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
102
diff
changeset
|
165 |
/** |
0 | 166 |
Give pages to paging system for managing. |
167 |
*/ |
|
168 |
void DonatePages(TUint aCount, TPhysAddr* aPages); |
|
169 |
||
170 |
/** |
|
171 |
Reclaim pages from paging system which were previously donated with DonatePages. |
|
172 |
||
173 |
@param aCount Number of pages. |
|
174 |
@param aPages Array of pages (as stored in an RPageArray). |
|
175 |
||
176 |
@return KErrNone if successful. |
|
177 |
KErrNoMemory if paging system doesn't have enough spare pages. This will leave some or all of the pages still managed by the pager. |
|
178 |
KErrNotFound if some of the pages were not actually being managed by the pager. |
|
179 |
*/ |
|
180 |
TInt ReclaimPages(TUint aCount, TPhysAddr* aPages); |
|
181 |
||
182 |
/** |
|
183 |
Called by class Mmu whenever a page of RAM is freed. The page state will be EUnused. |
|
184 |
If the page was being used by the pager then this gives it the opportunity to update |
|
185 |
any internal state. If the pager wishes to retain ownership of the page the it must |
|
186 |
return the result KErrNone, any other value will cause the page to be returned to the |
|
187 |
systems free pool. |
|
188 |
*/ |
|
189 |
TInt PageFreed(SPageInfo* aPageInfo); |
|
190 |
||
191 |
// |
|
192 |
// following public members for use by memory managers... |
|
193 |
// |
|
194 |
||
195 |
/** |
|
196 |
Allocate a number of RAM pages to store demand paged content. |
|
197 |
These pages are obtained from... |
|
198 |
||
199 |
1. An unused page in the live page list. |
|
200 |
2. The systems free pool. |
|
201 |
3. The oldest page from the live page list. |
|
202 |
*/ |
|
203 |
TInt PageInAllocPages(TPhysAddr* aPages, TUint aCount, Mmu::TRamAllocFlags aAllocFlags); |
|
204 |
||
205 |
/** |
|
206 |
Free a number of RAM pages allocated by PageInAllocPages. |
|
207 |
*/ |
|
208 |
void PageInFreePages(TPhysAddr* aPages, TUint aCount); |
|
209 |
||
210 |
/** |
|
211 |
Called to add a new page to the live list after a fault has occurred. |
|
212 |
||
213 |
@param aPageInfo The page. |
|
214 |
||
215 |
@pre MmuLock held |
|
216 |
@post MmuLock held (but may have been released by this function) |
|
217 |
*/ |
|
218 |
void PagedIn(SPageInfo* aPageInfo); |
|
219 |
||
220 |
/** |
|
221 |
@param aPageInfo The page. |
|
222 |
@param aPinArgs Owner of a replacement page which will be used to substitute for the pinned page. |
|
223 |
||
224 |
@pre MmuLock held |
|
225 |
@post MmuLock held (but may have been released by this function) |
|
226 |
*/ |
|
227 |
void PagedInPinned(SPageInfo* aPageInfo, TPinArgs& aPinArgs); |
|
228 |
||
229 |
/** |
|
230 |
@pre MmuLock held |
|
231 |
@post MmuLock left unchanged. |
|
232 |
*/ |
|
233 |
void PagedInUnneeded(SPageInfo* aPageInfo); |
|
234 |
||
235 |
/** |
|
236 |
@param aPageInfo The page to unpin. |
|
237 |
@param aPinArgs The resources used for pinning. The replacement pages allocated |
|
238 |
to this will be increased for each page which was became completely |
|
239 |
unpinned. |
|
240 |
||
241 |
@pre MmuLock held |
|
242 |
@post MmuLock held (but may have been released by this function) |
|
243 |
*/ |
|
244 |
void Unpin(SPageInfo* aPageInfo, TPinArgs& aPinArgs); |
|
245 |
||
246 |
/** |
|
247 |
@param aPageInfo The page to pin. Must be page being demand paged. |
|
248 |
@param aPinArgs Owner of a replacement page which will be used to substitute for the pinned page. |
|
249 |
||
250 |
@pre MmuLock held |
|
251 |
@post MmuLock held (but may have been released by this function) |
|
252 |
*/ |
|
253 |
void Pin(SPageInfo* aPageInfo, TPinArgs& aPinArgs); |
|
254 |
||
255 |
||
256 |
/** |
|
257 |
@pre MmuLock held |
|
258 |
@post MmuLock held (but may have been released by this function) |
|
259 |
*/ |
|
260 |
void RejuvenatePageTable(TPte* aPt); |
|
261 |
||
262 |
/** |
|
263 |
*/ |
|
264 |
TBool ReservePages(TUint aRequiredCount, TUint& aCount); |
|
265 |
||
266 |
/** |
|
267 |
*/ |
|
268 |
void UnreservePages(TUint& aCount); |
|
269 |
||
270 |
/** |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
271 |
Indicates whether there are any dirty pages available to be cleaned by #CleanSomePages. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
272 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
273 |
This is called by the page cleaner to work out whether it has any work to do. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
274 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
275 |
@return Whether there are any dirty pages in the oldest section of the live list. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
276 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
277 |
TBool HasPagesToClean(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
278 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
279 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
280 |
Attempt to clean one or more dirty pages in one go. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
281 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
282 |
Called by the page cleaner to clean pages and by PageInAllocPage when needs to steal a page from |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
283 |
the live list, but the oldest clean list is empty. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
284 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
285 |
May or may not succeed in acually cleaning any pages. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
286 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
287 |
@param aBackground Whether the activity should be ignored when determining whether the paging |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
288 |
device is busy. This is used by the page cleaner. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
289 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
290 |
@return The number of pages this method attempted to clean. If it returns zero, there were no |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
291 |
pages eligible to be cleaned. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
292 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
293 |
TInt CleanSomePages(TBool aBackground); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
294 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
295 |
/** |
0 | 296 |
Enumeration of instrumented paging events which only require the |
297 |
SPageInfo object as an argument. |
|
298 |
*/ |
|
299 |
enum TEventSimple |
|
300 |
{ |
|
301 |
EEventPageInNew, |
|
302 |
EEventPageInAgain, |
|
303 |
EEventPageInUnneeded, |
|
304 |
EEventPageInFree, |
|
305 |
EEventPageOut, |
|
306 |
EEventPageAged, |
|
307 |
EEventPagePin, |
|
308 |
EEventPageUnpin, |
|
309 |
EEventPageDonate, |
|
310 |
EEventPageReclaim, |
|
311 |
EEventPageAgedClean, |
|
312 |
EEventPageAgedDirty, |
|
313 |
EEventPagePageTableAlloc |
|
314 |
}; |
|
315 |
||
316 |
/** |
|
317 |
Signal the occurrence of an event of type TEventSimple. |
|
318 |
*/ |
|
319 |
void Event(TEventSimple aEvent, SPageInfo* aPageInfo); |
|
320 |
||
321 |
/** |
|
322 |
Enumeration of instrumented paging events which require the faulting address |
|
323 |
and program counter as arguments. |
|
324 |
*/ |
|
325 |
enum TEventWithAddresses |
|
326 |
{ |
|
327 |
EEventPageInStart, |
|
328 |
EEventPageRejuvenate |
|
329 |
}; |
|
330 |
||
331 |
/** |
|
332 |
Signal the occurrence of an event of type TEventWithAddresses. |
|
333 |
*/ |
|
334 |
void Event(TEventWithAddresses aEvent, SPageInfo* aPageInfo, TLinAddr aPc, TLinAddr aFaultAddress, TUint aAccessPermissions); |
|
335 |
||
336 |
/** |
|
337 |
Get the pager's event info data. |
|
338 |
*/ |
|
339 |
void GetEventInfo(SVMEventInfo& aInfoOut); |
|
340 |
||
341 |
/** |
|
342 |
Reset the pager's event info data. |
|
343 |
*/ |
|
344 |
void ResetEventInfo(); |
|
345 |
||
346 |
/** |
|
347 |
Attempt to discard the specified page. |
|
348 |
||
349 |
@param aOldPageInfo The page info of the page to discard. |
|
350 |
@param aBlockZoneId The ID of the RAM zone not to allocate any required new page into. |
|
351 |
@param aBlockRest Set to ETrue when we don't want the allocator to search for new pages if the RAM |
|
352 |
zone with ID==aBlockZoneId is encountered, i.e. a general RAM defrag operation. |
|
353 |
*/ |
|
354 |
TInt DiscardPage(SPageInfo* aOldPageInfo, TUint aBlockZoneId, TBool aBlockRest); |
|
355 |
||
356 |
||
357 |
/** |
|
358 |
Update any live list links to replace the old page with the new page. |
|
359 |
This is to be used when a page has been moved. |
|
360 |
||
361 |
@param aOldPageInfo The page info of the page to replace. |
|
362 |
@param aNewPageInfo The page info of the page to be used instead of the old page. |
|
363 |
*/ |
|
364 |
void ReplacePage(SPageInfo& aOldPageInfo, SPageInfo& aNewPageInfo); |
|
365 |
||
366 |
||
367 |
// |
|
368 |
// following public members for use by TPinArgs... |
|
369 |
// |
|
370 |
||
371 |
/** |
|
372 |
*/ |
|
373 |
TBool AllocPinReplacementPages(TUint aNumPages); |
|
374 |
||
375 |
/** |
|
376 |
*/ |
|
377 |
void FreePinReplacementPages(TUint aNumPages); |
|
378 |
||
379 |
private: |
|
380 |
/** |
|
381 |
Add a page to the head of the live page list. I.e. make it the 'youngest' page. |
|
382 |
||
383 |
@pre MmuLock held |
|
384 |
@post MmuLock left unchanged. |
|
385 |
*/ |
|
386 |
void AddAsYoungestPage(SPageInfo* aPageInfo); |
|
387 |
||
388 |
/** |
|
389 |
Mark a page as type EUnused and add it to the end of the live page list. |
|
390 |
I.e. make it the 'oldest' page, so that it is the first page to be reused. |
|
391 |
||
392 |
@pre MmuLock held |
|
393 |
@post MmuLock left unchanged. |
|
394 |
*/ |
|
395 |
void AddAsFreePage(SPageInfo* aPageInfo); |
|
396 |
||
397 |
/** |
|
398 |
Remove a page from live page list. |
|
399 |
It paged state is set to EUnpaged. |
|
400 |
||
401 |
@pre MmuLock held |
|
402 |
@post MmuLock left unchanged. |
|
403 |
*/ |
|
404 |
void RemovePage(SPageInfo* aPageInfo); |
|
405 |
||
406 |
/** |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
407 |
Try to remove the oldest page from the live page list and perform #StealPage. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
408 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
409 |
@param aPageInfoOut Set to the SPageInfo pointer for the stolen page if any. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
410 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
411 |
@return KErrNone on success, KErrInUse if stealing failed or 1 to indicate the the oldest page |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
412 |
was dirty and the PageCleaning mutex was not held. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
413 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
414 |
@pre MmuLock held |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
415 |
@post MmuLock left unchanged. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
416 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
417 |
TInt TryStealOldestPage(SPageInfo*& aPageInfoOut); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
418 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
419 |
/** |
0 | 420 |
Remove the oldest page from the live page list and perform #StealPage. |
421 |
||
422 |
@pre MmuLock held |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
423 |
@post MmuLock held (but may have been released by this function) |
0 | 424 |
*/ |
425 |
SPageInfo* StealOldestPage(); |
|
426 |
||
427 |
/** |
|
428 |
Steal a page from the memory object (if any) which is using the page. |
|
429 |
If successful the returned page will be in the EUnknown state and the |
|
430 |
cache state for the page is indeterminate. This is the same state as |
|
431 |
if the page had been allocated by Mmu::AllocRam. |
|
432 |
||
433 |
@pre RamAlloc mutex held |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
434 |
@pre If the page is dirty the PageCleaning lock must be held. |
0 | 435 |
@pre MmuLock held |
436 |
@post MmuLock held (but may have been released by this function) |
|
437 |
*/ |
|
438 |
TInt StealPage(SPageInfo* aPageInfo); |
|
439 |
||
440 |
/** |
|
441 |
Restrict the access permissions for a page. |
|
442 |
||
443 |
@param aPageInfo The page. |
|
444 |
@param aRestriction The restriction type to apply. |
|
445 |
*/ |
|
446 |
TInt RestrictPage(SPageInfo* aPageInfo, TRestrictPagesType aRestriction); |
|
447 |
||
448 |
/** |
|
449 |
Get a RAM page from the system's free pool and add it to the live list as a free page. |
|
450 |
||
451 |
@return False if out of memory; |
|
452 |
true otherwise, though new free page may still have already been used. |
|
453 |
||
454 |
@pre MmuLock held |
|
455 |
@post MmuLock held (but may have been released by this function) |
|
456 |
*/ |
|
457 |
TBool TryGrowLiveList(); |
|
458 |
||
459 |
/** |
|
460 |
Get a RAM page from the system's free pool. |
|
461 |
||
462 |
@pre RamAllocLock held. |
|
463 |
||
464 |
@return The page or NULL if no page is available. |
|
465 |
*/ |
|
466 |
SPageInfo* GetPageFromSystem(Mmu::TRamAllocFlags aAllocFlags, TUint aBlockZoneId=KRamZoneInvalidId, TBool aBlockRest=EFalse); |
|
467 |
||
468 |
/** |
|
469 |
Put a page back on the system's free pool. |
|
470 |
||
471 |
@pre RamAllocLock held. |
|
472 |
*/ |
|
473 |
void ReturnPageToSystem(); |
|
474 |
||
475 |
/** |
|
476 |
Put a specific page back on the system's free pool. |
|
477 |
||
478 |
@pre RamAllocLock held. |
|
479 |
*/ |
|
480 |
void ReturnPageToSystem(SPageInfo& aPageInfo); |
|
481 |
||
482 |
/** |
|
483 |
Allocate a RAM page to store demand paged content. |
|
484 |
This tries to obtain a RAM from the following places: |
|
485 |
1. An unused page in the live page list. |
|
486 |
2. The systems free pool. |
|
487 |
3. The oldest page from the live page list. |
|
488 |
*/ |
|
489 |
SPageInfo* PageInAllocPage(Mmu::TRamAllocFlags aAllocFlags); |
|
490 |
||
491 |
/** |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
492 |
Called by CleanSomePages() to determine which pages should be cleaned. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
493 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
494 |
This deals with the complexity of page colouring, which means that pages can only be mapped at |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
495 |
certain locations. When cleaning multiple pages at once we need to find a set of pages that we |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
496 |
can map in memory sequentially. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
497 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
498 |
@pre MmuLock held |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
499 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
500 |
@param aPageInfosOut Pointer to an array of SPageInfo pointers, which must be at least |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
501 |
KMaxPagesToClean long. This will be filled in to indicate the pages to clean. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
502 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
503 |
@return The numnber of pages to clean. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
504 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
505 |
TInt SelectPagesToClean(SPageInfo** aPageInfosOut); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
506 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
507 |
/** |
0 | 508 |
If the number of young pages exceeds that specified by iYoungOldRatio then a |
509 |
single page is made 'old'. Call this after adding a new 'young' page. |
|
510 |
||
511 |
@pre MmuLock held |
|
512 |
@post MmuLock held (but may have been released by this function) |
|
513 |
*/ |
|
514 |
void BalanceAges(); |
|
515 |
||
516 |
/** |
|
517 |
If HaveTooManyPages() then return them to the system. |
|
518 |
*/ |
|
519 |
void RemoveExcessPages(); |
|
520 |
||
521 |
/** |
|
522 |
@return True if pager has too many pages, false otherwise. |
|
523 |
*/ |
|
524 |
TBool HaveTooManyPages(); |
|
525 |
||
526 |
/** |
|
527 |
@return True if pager has its maximum number of pages, false otherwise. |
|
528 |
*/ |
|
529 |
TBool HaveMaximumPages(); |
|
530 |
||
531 |
/** |
|
532 |
Attempt to rejuvenate a page in which a page fault occurred. |
|
533 |
||
534 |
@param aOsAsid Address space ID in which fault occurred. |
|
535 |
@param aAddress Address of memory access which faulted. |
|
536 |
@param aAccessPermissions Bitmask of values from enum TAccessPermissions, which |
|
537 |
indicates the permissions required by faulting memory access. |
|
538 |
@param aPc Address of instruction causing the fault. (Used for tracing.) |
|
539 |
@param aMapping The mapping that maps the page that took the fault. |
|
540 |
@param aMapInstanceCount The instance count of the mappig when the page fault occurred. |
|
541 |
@param aThread The thread that took the page fault. |
|
542 |
@param aExceptionInfo The processor specific exception info. |
|
543 |
||
544 |
@return KErrNone if the page was remapped, KErrAbort if the mapping has be reused or detached, |
|
545 |
KErrNotFound if it may be possible to page in the page. |
|
546 |
*/ |
|
547 |
TInt TryRejuvenate( TInt aOsAsid, TLinAddr aAddress, TUint aAccessPermissions, TLinAddr aPc, |
|
548 |
DMemoryMappingBase* aMapping, TUint aMapInstanceCount, DThread* aThread, |
|
549 |
TAny* aExceptionInfo); |
|
550 |
||
551 |
/** |
|
552 |
Reserve one page for guaranteed locking use. |
|
553 |
Increments iReservePageCount if successful. |
|
554 |
||
555 |
@return True if operation was successful. |
|
556 |
*/ |
|
557 |
TBool ReservePage(); |
|
558 |
||
559 |
/** |
|
560 |
Called when a realtime thread takes a paging fault. |
|
561 |
Checks whether it's OK for the thread to take to fault. |
|
562 |
@return KErrNone if the paging fault should be further processed |
|
563 |
*/ |
|
564 |
TInt CheckRealtimeThreadFault(DThread* aThread, TAny* aExceptionInfo); |
|
565 |
||
566 |
/** |
|
567 |
Attempt to find the page table entry and page info for a page in the specified mapping. |
|
568 |
||
569 |
@param aOsAsid The OsAsid of the process that owns the mapping. |
|
570 |
@param aAddress The linear address of the page. |
|
571 |
@param aMapping The mapping that maps the linear address. |
|
572 |
@param aMapInstanceCount The instance count of the mapping. |
|
573 |
@param[out] aPte Will return a pointer to the page table entry for the page. |
|
574 |
@param[out] aPageInfo Will return a pointer to the page info for the page. |
|
575 |
||
576 |
@return KErrNone on success, KErrAbort when the mapping is now invalid, KErrNotFound when |
|
577 |
the page table or page info can't be found. |
|
578 |
*/ |
|
579 |
TInt PteAndInfoFromLinAddr( TInt aOsAsid, TLinAddr aAddress, DMemoryMappingBase* aMapping, |
|
580 |
TUint aMapInstanceCount, TPte*& aPte, SPageInfo*& aPageInfo); |
|
581 |
#ifdef _DEBUG |
|
582 |
/** |
|
583 |
Check consistency of live list. |
|
584 |
*/ |
|
585 |
TBool CheckLists(); |
|
586 |
||
587 |
void TraceCounts(); |
|
588 |
#endif |
|
589 |
||
590 |
private: |
|
591 |
TUint iMinYoungPages; ///< Minimum number of young pages in live list required for correct functioning. |
|
592 |
TUint iAbsoluteMinPageCount;///< Absolute minimum number of pages in live to meet algorithm constraints |
|
593 |
private: |
|
594 |
TUint iMinimumPageCount; /**< Minimum size for the live page list, including locked pages */ |
|
595 |
TUint iMaximumPageCount; /**< Maximum size for the live page list, including locked pages */ |
|
596 |
TUint16 iYoungOldRatio; /**< Ratio of young to old pages in the live page list */ |
|
597 |
SDblQue iYoungList; /**< Head of 'young' page list. */ |
|
598 |
TUint iYoungCount; /**< Number of young pages */ |
|
599 |
SDblQue iOldList; /**< Head of 'old' page list. */ |
|
600 |
TUint iOldCount; /**< Number of old pages */ |
|
601 |
SDblQue iOldestCleanList; /**< Head of 'oldestClean' page list. */ |
|
602 |
TUint iOldestCleanCount; /**< Number of 'oldestClean' pages */ |
|
603 |
SDblQue iOldestDirtyList; /**< Head of 'oldestDirty' page list. */ |
|
604 |
TUint iOldestDirtyCount; /**< Number of 'oldestDirty' pages */ |
|
605 |
TUint16 iOldOldestRatio; /**< Ratio of old pages to oldest to clean and dirty in the live page list*/ |
|
606 |
TUint iNumberOfFreePages; |
|
607 |
TUint iNumberOfDirtyPages; /**< The total number of dirty pages in the paging cache. Protected by MmuLock */ |
|
608 |
TUint iInitMinimumPageCount;/**< Initial value for iMinimumPageCount */ |
|
609 |
TUint iInitMaximumPageCount;/**< Initial value for iMaximumPageCount */ |
|
610 |
TUint iReservePageCount; /**< Number of pages reserved for locking */ |
|
611 |
TUint iMinimumPageLimit; /**< Minimum size for iMinimumPageCount, not including locked pages. |
|
612 |
iMinimumPageCount >= iMinimumPageLimit + iReservePageCount */ |
|
613 |
SVMEventInfo iEventInfo; |
|
614 |
||
615 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
616 |
public: |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
617 |
void RecordBenchmarkData(TPagingBenchmark aBm, TUint32 aStartTime, TUint32 aEndTime, TUint aCount); |
0 | 618 |
void ResetBenchmarkData(TPagingBenchmark aBm); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
619 |
void ReadBenchmarkData(TPagingBenchmark aBm, SPagingBenchmarkInfo& aDataOut); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
620 |
TSpinLock iBenchmarkLock; |
0 | 621 |
SPagingBenchmarkInfo iBenchmarkInfo[EMaxPagingBm]; |
622 |
#endif //__DEMAND_PAGING_BENCHMARKS__ |
|
623 |
}; |
|
624 |
||
625 |
extern DPager ThePager; |
|
626 |
||
627 |
||
628 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
629 |
||
630 |
#define START_PAGING_BENCHMARK TUint32 _bmStart = NKern::FastCounter() |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
631 |
#define END_PAGING_BENCHMARK(bm) ThePager.RecordBenchmarkData(bm, _bmStart, NKern::FastCounter(), 1) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
632 |
#define END_PAGING_BENCHMARK_N(bm, n) ThePager.RecordBenchmarkData(bm, _bmStart, NKern::FastCounter(), (n)) |
0 | 633 |
|
634 |
#else |
|
635 |
||
636 |
#define START_PAGING_BENCHMARK |
|
637 |
#define END_PAGING_BENCHMARK(bm) |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
638 |
#define END_PAGING_BENCHMARK_N(bm, n) |
0 | 639 |
#endif // __DEMAND_PAGING_BENCHMARKS__ |
640 |
||
641 |
||
642 |
FORCE_INLINE void DPager::Event(TEventSimple aEvent, SPageInfo* aPageInfo) |
|
643 |
{ |
|
644 |
switch(aEvent) |
|
645 |
{ |
|
646 |
case EEventPageInNew: |
|
647 |
TRACEP(("DP: %O PageIn 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
648 |
#ifdef BTRACE_PAGING |
|
649 |
BTraceContext12(BTrace::EPaging,BTrace::EPagingPageIn,aPageInfo->PhysAddr(),aPageInfo->Owner(),aPageInfo->Index()); |
|
650 |
#endif |
|
651 |
++iEventInfo.iPageInReadCount; |
|
652 |
break; |
|
653 |
||
654 |
case EEventPageInAgain: |
|
655 |
TRACEP(("DP: %O PageIn (again) 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
656 |
#ifdef BTRACE_PAGING |
|
657 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingMapPage,aPageInfo->PhysAddr()); |
|
658 |
#endif |
|
659 |
break; |
|
660 |
||
661 |
case EEventPageInUnneeded: |
|
662 |
TRACEP(("DP: %O PageIn (unneeded) 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
663 |
#ifdef BTRACE_PAGING |
|
664 |
BTraceContext0(BTrace::EPaging,BTrace::EPagingPageInUnneeded); |
|
665 |
#endif |
|
666 |
break; |
|
667 |
||
668 |
case EEventPageInFree: |
|
669 |
TRACEP(("DP: %O PageInFree 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
670 |
#ifdef BTRACE_PAGING |
|
671 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingPageInFree,aPageInfo->PhysAddr()); |
|
672 |
#endif |
|
673 |
break; |
|
674 |
||
675 |
case EEventPageOut: |
|
676 |
TRACEP(("DP: %O PageOut 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
677 |
#ifdef BTRACE_PAGING |
|
678 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingPageOut,aPageInfo->PhysAddr()); |
|
679 |
#endif |
|
680 |
break; |
|
681 |
||
682 |
case EEventPageAged: |
|
683 |
TRACEP(("DP: %O Aged 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
684 |
#ifdef BTRACE_PAGING_VERBOSE |
|
685 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingAged,aPageInfo->PhysAddr()); |
|
686 |
#endif |
|
687 |
break; |
|
688 |
||
689 |
case EEventPagePin: |
|
690 |
TRACEP(("DP: %O Pin 0x%08x count=%d",TheCurrentThread,aPageInfo->PhysAddr(),aPageInfo->PinCount())); |
|
691 |
#ifdef BTRACE_PAGING |
|
692 |
BTraceContext8(BTrace::EPaging,BTrace::EPagingPageLock,aPageInfo->PhysAddr(),aPageInfo->PinCount()); |
|
693 |
#endif |
|
694 |
break; |
|
695 |
||
696 |
case EEventPageUnpin: |
|
697 |
TRACEP(("DP: %O Unpin 0x%08x count=%d",TheCurrentThread,aPageInfo->PhysAddr(),aPageInfo->PinCount())); |
|
698 |
#ifdef BTRACE_PAGING |
|
699 |
BTraceContext8(BTrace::EPaging,BTrace::EPagingPageUnlock,aPageInfo->PhysAddr(),aPageInfo->PinCount()); |
|
700 |
#endif |
|
701 |
break; |
|
702 |
||
703 |
case EEventPageDonate: |
|
704 |
TRACEP(("DP: %O Donate 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
705 |
#ifdef BTRACE_PAGING |
|
706 |
BTraceContext12(BTrace::EPaging,BTrace::EPagingDonatePage,aPageInfo->PhysAddr(),aPageInfo->Owner(),aPageInfo->Index()); |
|
707 |
#endif |
|
708 |
break; |
|
709 |
||
710 |
case EEventPageReclaim: |
|
711 |
TRACEP(("DP: %O Reclaim 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
712 |
#ifdef BTRACE_PAGING |
|
713 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingReclaimPage,aPageInfo->PhysAddr()); |
|
714 |
#endif |
|
715 |
break; |
|
716 |
||
717 |
case EEventPageAgedClean: |
|
718 |
TRACEP(("DP: %O AgedClean 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
719 |
#ifdef BTRACE_PAGING_VERBOSE |
|
720 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingAgedClean,aPageInfo->PhysAddr()); |
|
721 |
#endif |
|
722 |
break; |
|
723 |
||
724 |
case EEventPageAgedDirty: |
|
725 |
TRACEP(("DP: %O AgedDirty 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
726 |
#ifdef BTRACE_PAGING_VERBOSE |
|
727 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingAgedDirty,aPageInfo->PhysAddr()); |
|
728 |
#endif |
|
729 |
break; |
|
730 |
||
731 |
case EEventPagePageTableAlloc: |
|
732 |
TRACEP(("DP: %O PageTableAlloc 0x%08x",TheCurrentThread,aPageInfo->PhysAddr())); |
|
733 |
#ifdef BTRACE_PAGING |
|
734 |
BTraceContext4(BTrace::EPaging,BTrace::EPagingPageTableAlloc,aPageInfo->PhysAddr()); |
|
735 |
#endif |
|
736 |
break; |
|
737 |
||
738 |
default: |
|
739 |
__NK_ASSERT_DEBUG(0); |
|
740 |
break; |
|
741 |
} |
|
742 |
} |
|
743 |
||
744 |
||
745 |
||
746 |
FORCE_INLINE void DPager::Event(TEventWithAddresses aEvent, SPageInfo* aPageInfo, TLinAddr aPc, TLinAddr aFaultAddress, TUint aAccessPermissions) |
|
747 |
{ |
|
748 |
switch(aEvent) |
|
749 |
{ |
|
750 |
case EEventPageInStart: |
|
751 |
TRACEP(("DP: %O HandlePageFault 0x%08x 0x%08x %d",TheCurrentThread,aFaultAddress,aPc,aAccessPermissions)); |
|
752 |
#ifdef BTRACE_PAGING |
|
753 |
BTraceContext12(BTrace::EPaging,BTrace::EPagingPageInBegin,aFaultAddress,aPc,aAccessPermissions); |
|
754 |
#endif |
|
755 |
++iEventInfo.iPageFaultCount; |
|
756 |
break; |
|
757 |
||
758 |
case EEventPageRejuvenate: |
|
759 |
TRACEP(("DP: %O Rejuvenate 0x%08x 0x%08x 0x%08x %d",TheCurrentThread,aPageInfo->PhysAddr(),aFaultAddress,aPc,aAccessPermissions)); |
|
760 |
#ifdef BTRACE_PAGING |
|
761 |
BTraceContext12(BTrace::EPaging,BTrace::EPagingRejuvenate,aPageInfo->PhysAddr(),aFaultAddress,aPc); |
|
762 |
#endif |
|
763 |
++iEventInfo.iPageFaultCount; |
|
764 |
break; |
|
765 |
||
766 |
default: |
|
767 |
__NK_ASSERT_DEBUG(0); |
|
768 |
break; |
|
769 |
} |
|
770 |
} |
|
771 |
||
772 |
||
773 |
||
774 |
/** |
|
775 |
Multiplier for number of request objects in pool per drive that supports paging. |
|
776 |
*/ |
|
777 |
const TInt KPagingRequestsPerDevice = 2; |
|
778 |
||
779 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
780 |
class DPoolPagingRequest; |
0 | 781 |
class DPageReadRequest; |
782 |
class DPageWriteRequest; |
|
783 |
||
784 |
/** |
|
785 |
A pool of paging requests for use by a single paging device. |
|
786 |
*/ |
|
787 |
class DPagingRequestPool : public DBase |
|
788 |
{ |
|
789 |
public: |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
790 |
DPagingRequestPool(TUint aNumPageReadRequest, TBool aWriteRequest); |
0 | 791 |
DPageReadRequest* AcquirePageReadRequest(DMemoryObject* aMemory, TUint aIndex, TUint aCount); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
792 |
DPageWriteRequest* AcquirePageWriteRequest(DMemoryObject** aMemory, TUint* aIndex, TUint aCount); |
0 | 793 |
private: |
794 |
~DPagingRequestPool(); |
|
795 |
private: |
|
796 |
class TGroup |
|
797 |
{ |
|
798 |
public: |
|
799 |
TGroup(TUint aNumRequests); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
800 |
DPoolPagingRequest* FindCollisionContiguous(DMemoryObject* aMemory, TUint aIndex, TUint aCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
801 |
DPoolPagingRequest* GetRequest(DMemoryObject* aMemory, TUint aIndex, TUint aCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
802 |
void Signal(DPoolPagingRequest* aRequest); |
0 | 803 |
public: |
804 |
TUint iNumRequests; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
805 |
DPoolPagingRequest** iRequests; |
0 | 806 |
SDblQue iFreeList; |
807 |
}; |
|
808 |
TGroup iPageReadRequests; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
809 |
DPageWriteRequest* iPageWriteRequest; |
0 | 810 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
811 |
friend class DPoolPagingRequest; |
0 | 812 |
friend class DPageReadRequest; |
813 |
friend class DPageWriteRequest; |
|
814 |
}; |
|
815 |
||
816 |
||
817 |
/** |
|
818 |
Resources needed to service a paging request. |
|
819 |
*/ |
|
820 |
class DPagingRequest : public SDblQueLink |
|
821 |
{ |
|
822 |
public: |
|
823 |
enum |
|
824 |
{ |
|
825 |
EMaxPages = 4 |
|
826 |
}; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
827 |
DPagingRequest(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
828 |
TLinAddr MapPages(TUint aColour, TUint aCount, TPhysAddr* aPages); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
829 |
void UnmapPages(TBool aIMBRequired); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
830 |
void SetUseContiguous(DMemoryObject* aMemory, TUint aIndex, TUint aCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
831 |
void SetUseDiscontiguous(DMemoryObject** aMemory, TUint* aIndex, TUint aCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
832 |
void ResetUse(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
833 |
TBool CheckUseContiguous(DMemoryObject* aMemory, TUint aIndex, TUint aCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
834 |
TBool CheckUseDiscontiguous(DMemoryObject** aMemory, TUint* aIndex, TUint aCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
835 |
TBool IsCollisionContiguous(DMemoryObject* aMemory, TUint aIndex, TUint aCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
836 |
public: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
837 |
DMutex* iMutex; /**< A mutex for synchronisation and priority inheritance. */ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
838 |
protected: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
839 |
Mmu::TTempMapping iTempMapping; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
840 |
private: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
841 |
// used to identify memory request is used for... |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
842 |
TUint iUseRegionCount; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
843 |
DMemoryObject* iUseRegionMemory[EMaxPages]; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
844 |
TUint iUseRegionIndex[EMaxPages]; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
845 |
}; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
846 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
847 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
848 |
__ASSERT_COMPILE(DPagingRequest::EMaxPages >= KMaxPagesToClean); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
849 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
850 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
851 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
852 |
A paging request that is part of a pool of similar request objects. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
853 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
854 |
class DPoolPagingRequest : public DPagingRequest |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
855 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
856 |
public: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
857 |
DPoolPagingRequest(DPagingRequestPool::TGroup& aPoolGroup); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
858 |
void Release(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
859 |
void Wait(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
860 |
void Signal(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
861 |
public: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
862 |
TInt iUsageCount; /**< How many threads are using or waiting for this object. */ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
863 |
private: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
864 |
DPagingRequestPool::TGroup& iPoolGroup; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
865 |
}; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
866 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
867 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
868 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
869 |
Resources needed to service a page in request. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
870 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
871 |
class DPageReadRequest : public DPoolPagingRequest |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
872 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
873 |
public: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
874 |
DPageReadRequest(DPagingRequestPool::TGroup& aPoolGroup); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
875 |
TInt Construct(); |
0 | 876 |
static TUint ReservedPagesRequired(); |
877 |
private: |
|
878 |
~DPageReadRequest(); // can't delete |
|
879 |
public: |
|
880 |
TLinAddr iBuffer; /**< A buffer to read compressed data into. Size is EMaxPages+1 pages.*/ |
|
881 |
private: |
|
882 |
DMemoryObject* iMemory; |
|
883 |
private: |
|
884 |
static TInt iAllocNext; |
|
885 |
}; |
|
886 |
||
887 |
||
888 |
FORCE_INLINE TUint DPageReadRequest::ReservedPagesRequired() |
|
889 |
{ |
|
890 |
return iAllocNext*EMaxPages; |
|
891 |
} |
|
892 |
||
893 |
||
894 |
/** |
|
895 |
Resources needed to service a page out request. |
|
896 |
*/ |
|
897 |
class DPageWriteRequest : public DPagingRequest |
|
898 |
{ |
|
899 |
public: |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
900 |
DPageWriteRequest(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
901 |
void Release(); |
0 | 902 |
private: |
903 |
~DPageWriteRequest(); // can't delete |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
904 |
}; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
905 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
906 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
907 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
908 |
Class providing access to the mutex used to protect page cleaning operations; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
909 |
this is the mutex DPager::iPageCleaningLock. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
910 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
911 |
class PageCleaningLock |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
912 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
913 |
public: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
914 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
915 |
Acquire the lock. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
916 |
The lock may be acquired multiple times by a thread, and will remain locked |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
917 |
until #Unlock has been used enough times to balance this. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
918 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
919 |
static void Lock(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
920 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
921 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
922 |
Release the lock. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
923 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
924 |
@pre The current thread has previously acquired the lock. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
925 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
926 |
static void Unlock(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
927 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
928 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
929 |
Return true if the current thread holds the lock. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
930 |
This is used for debug checks. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
931 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
932 |
static TBool IsHeld(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
933 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
934 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
935 |
Create the lock. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
936 |
Called by DPager::Init3(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
937 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
938 |
static void Init(); |
0 | 939 |
}; |
940 |
||
941 |
||
942 |
#endif |