source: rtems-docs/ada_user/partition_manager.rst @ 4783b0d

4.115
Last change on this file since 4783b0d was 4783b0d, checked in by Amar Takhar <amar@…>, on 01/17/16 at 16:37:28

Split document into seperate files by section.

  • Property mode set to 100644
File size: 12.2 KB
Line 
1Partition Manager
2#################
3
4.. index:: partitions
5
6Introduction
7============
8
9The partition manager provides facilities to
10dynamically allocate memory in fixed-size units.  The directives
11provided by the partition manager are:
12
13- ``rtems.partition_create`` - Create a partition
14
15- ``rtems.partition_ident`` - Get ID of a partition
16
17- ``rtems.partition_delete`` - Delete a partition
18
19- ``rtems.partition_get_buffer`` - Get buffer from a partition
20
21- ``rtems.partition_return_buffer`` - Return buffer to a partition
22
23Background
24==========
25
26Partition Manager Definitions
27-----------------------------
28.. index:: partition, definition
29
30A partition is a physically contiguous memory area
31divided into fixed-size buffers that can be dynamically
32allocated and deallocated... index:: buffers, definition
33
34Partitions are managed and maintained as a list of
35buffers.  Buffers are obtained from the front of the partition’s
36free buffer chain and returned to the rear of the same chain.
37When a buffer is on the free buffer chain, RTEMS uses two
38pointers of memory from each buffer as the free buffer chain.
39When a buffer is allocated, the entire buffer is available for application use.
40Therefore, modifying memory that is outside of an allocated
41buffer could destroy the free buffer chain or the contents of an
42adjacent allocated buffer.
43
44Building a Partition Attribute Set
45----------------------------------
46.. index:: partition attribute set, building
47
48In general, an attribute set is built by a bitwise OR
49of the desired attribute components.  The set of valid partition
50attributes is provided in the following table:
51
52- ``RTEMS.LOCAL`` - local partition (default)
53
54- ``RTEMS.GLOBAL`` - global partition
55
56Attribute values are specifically designed to be
57mutually exclusive, therefore bitwise OR and addition operations
58are equivalent as long as each attribute appears exactly once in
59the component list.  An attribute listed as a default is not
60required to appear in the attribute list, although it is a good
61programming practice to specify default attributes.  If all
62defaults are desired, the attribute``RTEMS.DEFAULT_ATTRIBUTES`` should be
63specified on this call.  The attribute_set parameter should be``RTEMS.GLOBAL`` to indicate that the partition
64is to be known globally.
65
66Operations
67==========
68
69Creating a Partition
70--------------------
71
72The ``rtems.partition_create`` directive creates a partition
73with a user-specified name.  The partition’s name, starting
74address, length and buffer size are all specified to the``rtems.partition_create`` directive.
75RTEMS allocates a Partition Control
76Block (PTCB) from the PTCB free list.  This data structure is
77used by RTEMS to manage the newly created partition.  The number
78of buffers in the partition is calculated based upon the
79specified partition length and buffer size. If successful,the
80unique partition ID is returned to the calling task.
81
82Obtaining Partition IDs
83-----------------------
84
85When a partition is created, RTEMS generates a unique
86partition ID and assigned it to the created partition until it
87is deleted.  The partition ID may be obtained by either of two
88methods.  First, as the result of an invocation of the``rtems.partition_create`` directive, the partition
89ID is stored in a user provided location.  Second, the partition
90ID may be obtained later using the ``rtems.partition_ident``
91directive.  The partition ID is used by other partition manager directives
92to access this partition.
93
94Acquiring a Buffer
95------------------
96
97A buffer can be obtained by calling the``rtems.partition_get_buffer`` directive.
98If a buffer is available, then
99it is returned immediately with a successful return code.
100Otherwise, an unsuccessful return code is returned immediately
101to the caller.  Tasks cannot block to wait for a buffer to
102become available.
103
104Releasing a Buffer
105------------------
106
107Buffers are returned to a partition’s free buffer
108chain with the ``rtems.partition_return_buffer`` directive.  This
109directive returns an error status code if the returned buffer
110was not previously allocated from this partition.
111
112Deleting a Partition
113--------------------
114
115The ``rtems.partition_delete`` directive allows a partition to
116be removed and returned to RTEMS.  When a partition is deleted,
117the PTCB for that partition is returned to the PTCB free list.
118A partition with buffers still allocated cannot be deleted.  Any
119task attempting to do so will be returned an error status code.
120
121Directives
122==========
123
124This section details the partition manager’s
125directives.  A subsection is dedicated to each of this manager’s
126directives and describes the calling sequence, related
127constants, usage, and status codes.
128
129PARTITION_CREATE - Create a partition
130-------------------------------------
131.. index:: create a partition
132
133**CALLING SEQUENCE:**
134
135.. code:: c
136
137    procedure Partition_Create (
138    Name             : in     RTEMS.Name;
139    Starting_Address : in     RTEMS.Address;
140    Length           : in     RTEMS.Unsigned32;
141    Buffer_Size      : in     RTEMS.Unsigned32;
142    Attribute_Set    : in     RTEMS.Attribute;
143    ID               :    out RTEMS.ID;
144    Result           :    out RTEMS.Status_Codes
145    );
146
147**DIRECTIVE STATUS CODES:**
148
149``RTEMS.SUCCESSFUL`` - partition created successfully
150``RTEMS.INVALID_NAME`` - invalid partition name
151``RTEMS.TOO_MANY`` - too many partitions created
152``RTEMS.INVALID_ADDRESS`` - address not on four byte boundary
153``RTEMS.INVALID_ADDRESS`` - ``starting_address`` is NULL
154``RTEMS.INVALID_ADDRESS`` - ``id`` is NULL
155``RTEMS.INVALID_SIZE`` - length or buffer size is 0
156``RTEMS.INVALID_SIZE`` - length is less than the buffer size
157``RTEMS.INVALID_SIZE`` - buffer size not a multiple of 4
158``RTEMS.MP_NOT_CONFIGURED`` - multiprocessing not configured
159``RTEMS.TOO_MANY`` - too many global objects
160
161**DESCRIPTION:**
162
163This directive creates a partition of fixed size
164buffers from a physically contiguous memory space which starts
165at starting_address and is length bytes in size.  Each allocated
166buffer is to be of ``buffer_size`` in bytes.  The assigned
167partition id is returned in ``id``.  This partition id is used to
168access the partition with other partition related directives.
169For control and maintenance of the partition, RTEMS allocates a
170PTCB from the local PTCB free pool and initializes it.
171
172**NOTES:**
173
174This directive will not cause the calling task to be
175preempted.
176
177The ``starting_address`` must be properly aligned for the
178target architecture.
179
180The ``buffer_size`` parameter must be a multiple of
181the CPU alignment factor.  Additionally, ``buffer_size``
182must be large enough to hold two pointers on the target
183architecture.  This is required for RTEMS to manage the
184buffers when they are free.
185
186Memory from the partition is not used by RTEMS to
187store the Partition Control Block.
188
189The following partition attribute constants are
190defined by RTEMS:
191
192- ``RTEMS.LOCAL`` - local partition (default)
193
194- ``RTEMS.GLOBAL`` - global partition
195
196The PTCB for a global partition is allocated on the
197local node.  The memory space used for the partition must reside
198in shared memory. Partitions should not be made global unless
199remote tasks must interact with the partition.  This is to avoid
200the overhead incurred by the creation of a global partition.
201When a global partition is created, the partition’s name and id
202must be transmitted to every node in the system for insertion in
203the local copy of the global object table.
204
205The total number of global objects, including
206partitions, is limited by the maximum_global_objects field in
207the Configuration Table.
208
209PARTITION_IDENT - Get ID of a partition
210---------------------------------------
211.. index:: get ID of a partition
212.. index:: obtain ID of a partition
213
214**CALLING SEQUENCE:**
215
216.. code:: c
217
218    procedure Partition_Ident (
219    Name   : in     RTEMS.Name;
220    Node   : in     RTEMS.Unsigned32;
221    ID     :    out RTEMS.ID;
222    Result :    out RTEMS.Status_Codes
223    );
224
225**DIRECTIVE STATUS CODES:**
226
227``RTEMS.SUCCESSFUL`` - partition identified successfully
228``RTEMS.INVALID_ADDRESS`` - ``id`` is NULL
229``RTEMS.INVALID_NAME`` - partition name not found
230``RTEMS.INVALID_NODE`` - invalid node id
231
232**DESCRIPTION:**
233
234This directive obtains the partition id associated
235with the partition name.  If the partition name is not unique,
236then the partition id will match one of the partitions with that
237name.  However, this partition id is not guaranteed to
238correspond to the desired partition.  The partition id is used
239with other partition related directives to access the partition.
240
241**NOTES:**
242
243This directive will not cause the running task to be
244preempted.
245
246If node is ``RTEMS.SEARCH_ALL_NODES``, all nodes are searched
247with the local node being searched first.  All other nodes are
248searched with the lowest numbered node searched first.
249
250If node is a valid node number which does not
251represent the local node, then only the partitions exported by
252the designated node are searched.
253
254This directive does not generate activity on remote
255nodes.  It accesses only the local copy of the global object
256table.
257
258PARTITION_DELETE - Delete a partition
259-------------------------------------
260.. index:: delete a partition
261
262**CALLING SEQUENCE:**
263
264.. code:: c
265
266    procedure Partition_Delete (
267    ID     : in     RTEMS.ID;
268    Result :    out RTEMS.Status_Codes
269    );
270
271**DIRECTIVE STATUS CODES:**
272
273``RTEMS.SUCCESSFUL`` - partition deleted successfully
274``RTEMS.INVALID_ID`` - invalid partition id
275``RTEMS.RESOURCE_IN_USE`` - buffers still in use
276``RTEMS.ILLEGAL_ON_REMOTE_OBJECT`` - cannot delete remote partition
277
278**DESCRIPTION:**
279
280This directive deletes the partition specified by id.
281The partition cannot be deleted if any of its buffers are still
282allocated.  The PTCB for the deleted partition is reclaimed by
283RTEMS.
284
285**NOTES:**
286
287This directive will not cause the calling task to be
288preempted.
289
290The calling task does not have to be the task that
291created the partition.  Any local task that knows the partition
292id can delete the partition.
293
294When a global partition is deleted, the partition id
295must be transmitted to every node in the system for deletion
296from the local copy of the global object table.
297
298The partition must reside on the local node, even if
299the partition was created with the ``RTEMS.GLOBAL`` option.
300
301PARTITION_GET_BUFFER - Get buffer from a partition
302--------------------------------------------------
303.. index:: get buffer from partition
304.. index:: obtain buffer from partition
305
306**CALLING SEQUENCE:**
307
308.. code:: c
309
310    procedure Partition_Get_Buffer (
311    ID     : in     RTEMS.ID;
312    Buffer :    out RTEMS.Address;
313    Result :    out RTEMS.Status_Codes
314    );
315
316**DIRECTIVE STATUS CODES:**
317
318``RTEMS.SUCCESSFUL`` - buffer obtained successfully
319``RTEMS.INVALID_ADDRESS`` - ``buffer`` is NULL
320``RTEMS.INVALID_ID`` - invalid partition id
321``RTEMS.UNSATISFIED`` - all buffers are allocated
322
323**DESCRIPTION:**
324
325This directive allows a buffer to be obtained from
326the partition specified in id.  The address of the allocated
327buffer is returned in buffer.
328
329**NOTES:**
330
331This directive will not cause the running task to be
332preempted.
333
334All buffers begin on a four byte boundary.
335
336A task cannot wait on a buffer to become available.
337
338Getting a buffer from a global partition which does
339not reside on the local node will generate a request telling the
340remote node to allocate a buffer from the specified partition.
341
342PARTITION_RETURN_BUFFER - Return buffer to a partition
343------------------------------------------------------
344.. index:: return buffer to partitition
345
346**CALLING SEQUENCE:**
347
348.. code:: c
349
350    procedure Partition_Return_Buffer (
351    ID     : in     RTEMS.ID;
352    Buffer : in     RTEMS.Address;
353    Result :    out RTEMS.Status_Codes
354    );
355
356**DIRECTIVE STATUS CODES:**
357
358``RTEMS.SUCCESSFUL`` - buffer returned successfully
359``RTEMS.INVALID_ADDRESS`` - ``buffer`` is NULL
360``RTEMS.INVALID_ID`` - invalid partition id
361``RTEMS.INVALID_ADDRESS`` - buffer address not in partition
362
363**DESCRIPTION:**
364
365This directive returns the buffer specified by buffer
366to the partition specified by id.
367
368**NOTES:**
369
370This directive will not cause the running task to be
371preempted.
372
373Returning a buffer to a global partition which does
374not reside on the local node will generate a request telling the
375remote node to return the buffer to the specified partition.
376
377Returning a buffer multiple times is an error.  It will corrupt the internal
378state of the partition.
379
380.. COMMENT: COPYRIGHT (c) 1988-2002.
381
382.. COMMENT: On-Line Applications Research Corporation (OAR).
383
384.. COMMENT: All rights reserved.
385
Note: See TracBrowser for help on using the repository browser.