source: rtems/doc/user/part.t @ ca6c741

Last change on this file since ca6c741 was ca6c741, checked in by Joel Sherrill <joel.sherrill@…>, on 05/06/04 at 19:22:02

2004-05-06 Joel Sherrill <joel@…>

PR 618/rtems

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