source: rtems/doc/itron3.0/memorypool.t @ a5f5acad

4.104.114.84.95
Last change on this file since a5f5acad was a5f5acad, checked in by Joel Sherrill <joel.sherrill@…>, on 11/10/99 at 13:38:34

Updated to include more documentation from CS595.

  • Property mode set to 100644
File size: 13.8 KB
Line 
1@c
2@c  This is the chapter from the RTEMS ITRON User's Guide that
3@c  documents the services provided by the memory pool
4@c  manager.
5@c
6@c  $Id$
7@c
8
9@chapter Memory Pool Manager
10
11@section Introduction
12
13The
14memory pool manager is ...
15
16The services provided by the memory pool manager are:
17
18@itemize @bullet
19@item @code{cre_mpl} - Create Variable-Size Memorypool
20@item @code{del_mpl} - Delete Variable-Size Memorypool
21@item @code{get_blk} - Get Variable-Size Memory Block
22@item @code{pget_blk} - Poll and Get Variable-Size Memory Block
23@item @code{tget_blk} - Get Variable-Size Memory Block with Timeout
24@item @code{rel_blk} - Release Variable-Size Memory Block
25@item @code{ref_mpl} - Reference Variable-Size Memorypool Status
26@end itemize
27
28@section Background
29
30Memorypool management functions manage memorypools and allocate memory blocks.
31There are two types of memorypool: fixed-size memorypools and variable-size
32memorypools.  Both are considered separate objects and require different
33system calls for manipulation.  While the size of memory blocks allocated
34from fixed-size memorypools are all fixed, blocks of any size may be
35specified when allocating memory blocks from variable-size memorypools.
36
37@section Operations
38
39@section System Calls
40
41This section details the memory pool manager's services.
42A subsection is dedicated to each of this manager's services
43and describes the calling sequence, related constants, usage,
44and status codes.
45
46
47@c
48@c  cre_mpl
49@c
50
51@page
52@subsection cre_mpl - Create Variable-Size Memorypool
53
54@subheading CALLING SEQUENCE:
55
56@ifset is-C
57@example
58ER cre_mpl(
59  ID mplid,
60  T_CMPL *pk_cmpl
61);
62@end example
63@end ifset
64
65@ifset is-Ada
66@end ifset
67
68@subheading STATUS CODES:
69
70@code{E_OK} - Normal Completion
71
72@code{E_NOMEM} - Insufficient memory (Memory for control block and/or for
73memorypool cannot be allocated)
74
75@code{E_ID} - Invalid ID number (mplid was invalid or could not be used)
76
77@code{E_RSATR} - Reserved attribute (mplatr was invalid or could not be used)
78
79@code{E_OBJ} - Invalid object state (a memorypool of the same ID already exists)
80
81@code{E_OACV} - Object access violation (A mplid less than -4 was specified from
82a user task.  This is implementation dependent.)
83
84@code{E_PAR} - Parameter error (pk_cmpl is invalid or mplsz is negative or
85invalid)
86
87@subheading DESCRIPTION:
88
89The cre_mpl directive creates a variable-size memorypool having the ID number specified by mplid.  Specifically, a memory area of the size determined by mplsz is allocated for use as a memorypool.  A control block for the memorypool being created is also allocated.  User memorypools have positive ID numbers, while system memorypools have negative ID numbers.  User tasks (tasks having positive task IDs) cannot access system memorypools (memorypools having negative ID numbers).
90
91@subheading NOTES:
92
93The memory required for creating memorypools and for allocating control blocks for each object is reserved while system initialization. Associated parameters are therefore specified at system configuration.
94
95@c
96@c  del_mpl
97@c
98
99@page
100@subsection del_mpl - Delete Variable-Size Memorypool
101
102@subheading CALLING SEQUENCE:
103
104@ifset is-C
105@example
106ER del_mpl(
107  ID mplid
108);
109@end example
110@end ifset
111
112@ifset is-Ada
113@end ifset
114
115@subheading STATUS CODES:
116 
117@code{E_OK} - Normal Completion
118 
119@code{E_ID} - Invalid ID number (mplid was invalid or could not be used)
120 
121@code{E_NOEXS} - Object does not exist (the memorypool specified by mplid does not exist)
122 
123@code{E_OACV} - Object access violation (A mplid less than -4 was specified from
124a user task.  This is implementation dependent.)
125
126@subheading DESCRIPTION:
127
128This system call deletes the variable-size memorypool specified by mplid.  No check or error report is performed even if there are tasks using memory from the memorypool to be deleted.  This system call completes normally even if some of the memory blocks are not returned.  Issuing this system call causes memory used for the control block of the associated memorypool and the memory area making up the memorypool itself to be released.  After this system call is invoked, another memorypool having the same ID number can be created.
129
130@subheading NOTES:
131
132When a memorypool being waited for by more than one tasks is deleted, the order of tasks on the ready queue after the WAIT state is cleared is implementation dependent in the case of tasks having the same priority.
133
134@c
135@c  get_blk
136@c
137
138@page
139@subsection get_blk - Get Variable-Size Memory Block
140
141@subheading CALLING SEQUENCE:
142
143@ifset is-C
144@example
145ER get_blk(
146  VP *p_blk,
147  ID mplid,
148  INT blksz
149);
150@end example
151@end ifset
152
153@ifset is-Ada
154@end ifset
155
156@subheading STATUS CODES:
157
158@code{E_OK} - Normal Completion
159 
160@code{E_ID} - Invalid ID number (mplid was invalid or could not be used)
161 
162@code{E_NOEXS} - Object does not exist (the memorypool specified by mplid does not exist)
163 
164@code{E_OACV} - Object access violation (A mplid less than -4 was specified from
165a user task.  This is implementation dependent.)
166 
167@code{E_PAR} - Parameter error (tmout is -2 or less, blksz is negative or invalid)
168 
169@code{E_DLT} - The object being waited for was deleted (the specified memorypool
170was deleted while waiting)
171 
172@code{E_RLWAI} - WAIT state was forcibly released (rel_wai was received while
173waiting)
174 
175@code{E_TMOUT} - Polling failure or timeout
176
177@code{E_CTX} - Context error (issued from task-independent portions or a
178task in dispatch disabled state; implementation dependent for
179pget_blk and tget_blk(tmout=TMO_POL))
180
181@subheading DESCRIPTION:
182
183A memory block of the size in bytes given by blksz is allocated from the variable-size memorypool specified by mplid.  The start address of the memory block allocated is returned in blk.  The allocated memory block is not cleared to zero.  The contents of the memory block allocated are undefined.  If the memory block cannot be obtained from the specified memorypool when get_blk is issued, the task issuing get_blk will be placed on the memory allocation queue of the specified memorypool, and wait until it can get the memory it requires.
184
185The order in which tasks wait on the queue when waiting to be allocated memory blocks is according to either FIFO or task priority.  The specification whereby tasks wait according to task priority is considered an extended function [level X] for which compatibility is not guaranteed.  Furthermore, when tasks form a memory allocation queue, it is implementation dependent whether priority is given to tasks requesting the smaller size of memory or those at the head of the queue.
186
187@subheading NOTES:
188
189Pget_blk and get_blk represent the same processing as specifying certain values (TMO_POL or TMO_FEVR) to tget_blk for tmout.  It is allowed that only tget_blk is implemented in the kernel and that pget_blk and get_blk are implemented as macros which call tget_blk.
190
191@c
192@c  pget_blk
193@c
194
195@page
196@subsection pget_blk - Poll and Get Variable-Size Memory Block
197
198@subheading CALLING SEQUENCE:
199
200@ifset is-C
201@example
202ER ercd =pget_blk(
203  VP *p_blk,
204  ID mplid,
205  INT blksz
206);
207@end example
208@end ifset
209
210@ifset is-Ada
211@end ifset
212
213@subheading STATUS CODES:
214
215@code{E_OK} - Normal Completion
216 
217@code{E_ID} - Invalid ID number (mplid was invalid or could not be used)
218 
219@code{E_NOEXS} - Object does not exist (the memorypool specified by mplid does not exist)
220 
221@code{E_OACV} - Object access violation (A mplid less than -4 was specified from
222a user task.  This is implementation dependent.)
223 
224@code{E_PAR} - Parameter error (tmout is -2 or less, blksz is negative or invalid)
225
226@code{E_DLT} - The object being waited for was deleted (the specified memorypool
227was deleted while waiting)
228 
229@code{E_RLWAI} - WAIT state was forcibly released (rel_wai was received while
230waiting)
231 
232@code{E_TMOUT} - Polling failure or timeout
233 
234@code{E_CTX} - Context error (issued from task-independent portions or a
235task in dispatch disabled state; implementation dependent for
236pget_blk and tget_blk(tmout=TMO_POL))
237
238@subheading DESCRIPTION:
239
240The pget_blk system call has the same function as get_blk except for the waiting feature.  Pget_blk polls whether or not the task should wait if get_blk is executed.  The meaning of parameters to pget_blk are the same with get_blk.  The specific operations by pget_blk are as follows.
241
242  - If there is enough free memory to get the memory block of specified size
243    immediately, processing is the same as get_blk: that is, the
244    requested memory is allocated and the system call completes normally.
245
246  - If there is not enough free memory, an E_TMOUT error is returned to
247    indicate polling failed and the system call finishes.  Unlike get_blk,
248    the issuing task does not wait in this case.  Also, the issuing task
249    does not get any memory.
250
251@subheading NOTES:
252
253NONE
254
255@c
256@c  tget_blk
257@c
258
259@page
260@subsection tget_blk - Get Variable-Size Memory Block with Timeout
261
262@subheading CALLING SEQUENCE:
263
264@ifset is-C
265@example
266ER ercd =tget_blk(
267  VP *p_blk,
268  ID mplid,
269  INT blksz,
270  TMO tmout
271);
272@end example
273@end ifset
274
275@ifset is-Ada
276@end ifset
277
278@subheading STATUS CODES:
279
280@code{E_OK} - Normal Completion
281 
282@code{E_ID} - Invalid ID number (mplid was invalid or could not be used)
283 
284@code{E_NOEXS} - Object does not exist (the memorypool specified by mplid does not exist)
285 
286@code{E_OACV} - Object access violation (A mplid less than -4 was specified from
287a user task.  This is implementation dependent.)
288 
289@code{E_PAR} - Parameter error (tmout is -2 or less, blksz is negative or invalid)
290
291@code{E_DLT} - The object being waited for was deleted (the specified memorypool
292was deleted while waiting)
293 
294@code{E_RLWAI} - WAIT state was forcibly released (rel_wai was received while
295waiting)
296 
297@code{E_TMOUT} - Polling failure or timeout
298 
299@code{E_CTX} - Context error (issued from task-independent portions or a
300task in dispatch disabled state; implementation dependent for
301pget_blk and tget_blk(tmout=TMO_POL))
302
303
304@subheading DESCRIPTION:
305
306The tget_blk system call has the same function as get_blk with an additional timeout feature.  A maximum wait time (timeout value) can be specified using the parameter tmout.  When a timeout is specified, a timeout error, E_TMOUT, will result and the system call will finish if the period specified by tmout elapses without conditions for releasing wait being satisfied (i.e. without sufficient free memory becoming available).
307
308@subheading NOTES:
309
310NONE
311
312@c
313@c  rel_blk
314@c
315
316@page
317@subsection rel_blk - Release Variable-Size Memory Block
318
319@subheading CALLING SEQUENCE:
320
321@ifset is-C
322@example
323ER rel_blk(
324  ID mplid,
325  VP blk
326);
327@end example
328@end ifset
329
330@ifset is-Ada
331@end ifset
332
333@subheading STATUS CODES:
334 
335@code{E_OK} - Normal Completion
336 
337@code{E_ID} - Invalid ID number (mplid was invalid or could not be used)
338 
339@code{E_NOEXS} - Object does not exist (the memorypool specified by mplid does not exist)
340 
341@code{E_OACV} - Object access violation (A mplid less than -4 was specified from
342            a user task.  This is implementation dependent.)
343 
344@code{E_PAR} - Parameter error (blk is invalid or an attempt was made to return
345the memory block to the wrong memorypool)
346
347@subheading DESCRIPTION:
348
349This system call releases the memory block specified by blk and returns it to the variable-size memorypool specified by mplid.  Executing rel_blk allows memory to be allocated to the next task waiting for memory allocation from the memorypool given by mplid, thus releasing that task from its WAIT state.  The variable-size memorypool to which the memory block is returned must be the same memorypool from which it was originally allocated.  An E_PAR error will result if an attempt is made to return a memory block to another memorypool than that from which it was originally allocated.
350
351@subheading NOTES:
352
353When memory is returned to a variable-size memorypool for which more than one task is waiting, multiple tasks may be released from waiting at the same time depending on the number of bytes of memory.  The order of tasks on the ready queue among tasks having the same priority after being released from waiting for memory is implementation dependent.
354
355@c
356@c  ref_mpl
357@c
358
359@page
360@subsection ref_mpl - Reference Variable-Size Memorypool Status
361
362@subheading CALLING SEQUENCE:
363
364@ifset is-C
365@example
366ER ref_mpl(
367  T_RMPL *pk_rmpl,
368  ID mplid
369);
370@end example
371@end ifset
372
373@ifset is-Ada
374@end ifset
375
376@subheading STATUS CODES:
377 
378@code{E_OK} - Normal Completion
379 
380@code{E_ID} - Invalid ID number (mplid was invalid or could not be used)
381 
382@code{E_NOEXS} - Object does not exist (the memorypool specified by mplid does not exist)
383 
384@code{E_OACV} - Object access violation (A mplid less than -4 was specified from
385a user task.  This is implementation dependent.) Note: User tasks can issue ref_mpl in order to reference memorypools of mplid = TMPL_OS = -4.  Whether or not memorypools of mplid = -3 or -2 may be specified to ref_mpl by user tasks is implementation dependent.
386 
387@code{E_PAR} - Parameter error (the packet address for the return parameters
388could not be used)
389
390@subheading DESCRIPTION:
391
392This system call refers to the state of the variable-size memorypool specified by mplid, and returns the total free memory size currently available (frsz), the maximum continuous memory size of readily available free memory (maxsz), information of a task waiting to be allocated memory (wtsk), and its extended information (exinf).  Wtsk indicates, whether or not there is a task waiting to be allocated memory from the variable-size memorypool specified.  If there is no waiting task, wtsk is returned as FALSE = 0.  If there is a waiting task, wtsk is returned as a value other than 0.
393
394@subheading NOTES:
395
396In some implementations, memorypools having mplid = -3 or -2 may be referred with ref_mpl as memorypools used by implementation-dependent parts of the OS (such as those used for the stack only).  This system call can provide more detailed information regarding remaining memory if the usage of memorypools having mplid = -3 or -2 is more clearly defined.  Whether or not this feature is used and any details regarding information provided are implementation dependent.
397
Note: See TracBrowser for help on using the repository browser.