source: rtems/doc/user/concepts.t @ 35a81f8

4.104.114.84.95
Last change on this file since 35a81f8 was 35a81f8, checked in by Joel Sherrill <joel.sherrill@…>, on 05/15/07 at 20:17:21

2007-05-15 Joel Sherrill <joel.sherrill@…>

  • user/Makefile.am, user/concepts.t, user/rtmon.t: Integrate Rate Monotonic Statistics and Period Usage into Rate Monotonic Manager. Added the following directives: rtems_rate_monotonic_get_statistics, rtems_rate_monotonic_reset_statistics, rtems_rate_montonic_reset_all_statistics, rtems_rate_montonic_report_statistics, and rtems_object_get_name. Obsoleted the rtems/rtmonuse.h file as a public interface.
  • Property mode set to 100644
File size: 13.2 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@c
10@c  The following figure was replaced with an ASCII equivalent.
11@c    Figure 2-1 Object ID Composition
12@c
13
14@chapter Key Concepts
15
16@section Introduction
17
18The facilities provided by RTEMS are built upon a
19foundation of very powerful concepts.  These concepts must be
20understood before the application developer can efficiently
21utilize RTEMS.  The purpose of this chapter is to familiarize
22one with these concepts.
23
24@section Objects
25
26@cindex objects
27
28RTEMS provides directives which can be used to
29dynamically create, delete, and manipulate a set of predefined
30object types.  These types include tasks, message queues,
31semaphores, memory regions, memory partitions, timers, ports,
32and rate monotonic periods.  The object-oriented nature of RTEMS
33encourages the creation of modular applications built upon
34re-usable "building block" routines.
35
36All objects are created on the local node as required
37by the application and have an RTEMS assigned ID.  All objects
38have a user-assigned name.  Although a relationship exists
39between an object's name and its RTEMS assigned ID, the name and
40ID are not identical.  Object names are completely arbitrary and
41selected by the user as a meaningful "tag" which may commonly
42reflect the object's use in the application.  Conversely, object
43IDs are designed to facilitate efficient object manipulation by
44the executive.
45
46@subsection Object Names
47
48@cindex object name
49@findex rtems_object_name
50
51An object name is an unsigned thirty-two bit entity
52associated with the object by the user.  The data type
53@code{@value{DIRPREFIX}name} is used to store object names.
54
55@findex rtems_build_name
56
57Although not required by RTEMS, object names are often
58composed of four ASCII characters which help identify that object.
59For example, a task which causes a light to blink might be
60called "LITE".  The @code{@value{DIRPREFIX}build_name} routine
61is provided to build an object name from four ASCII characters. 
62@ifset is-C
63The following example illustrates this:
64
65@example
66rtems_object_name my_name;
67
68my_name = rtems_build_name( 'L', 'I', 'T', 'E' );
69@end example
70@end ifset
71
72However, it is not required that the application use ASCII
73characters to build object names.  For example, if an
74application requires one-hundred tasks, it would be difficult to
75assign meaningful ASCII names to each task.  A more convenient
76approach would be to name them the binary values one through
77one-hundred, respectively.
78
79@findex rtems_get_object_name
80
81RTEMS provides a helper routine, @code{@value{DIRPREFIX}get_object_name},
82which can be used to obtain the name of any RTEMS object using just
83its ID.  This routine attempts to convert the name into a printable string.
84
85@ifset is-C
86The following example illustrates the use of this method to print
87an object name:
88
89@example
90#include <rtems.h>
91#include <rtems/bspIo.h>
92
93void print_name(rtems_id the_object)
94@{
95  char  buffer[10];   /* name assumed to be 10 characters or less */
96  char *result;
97
98  result = rtems_get_object_name( id, sizeof(buffer), buffer );
99  printk( "ID=0x%08x name=%s\n", id, ((result) ? result : "no name") );
100@}
101@end example
102@end ifset
103
104
105@subsection Object IDs
106
107@cindex object ID
108@cindex object ID composition
109@findex rtems_id
110
111@need 3000
112
113An object ID is a unique unsigned thirty-two bit
114entity composed of three parts: object class, node, and index.
115The data type @code{@value{DIRPREFIX}id} is used to store object IDs.
116
117
118@ifset use-ascii
119@example
120@group
121     31        26 25              16 15                             0
122     +-----------+------------------+-------------------------------+
123     |           |                  |                               |
124     |   Class   |       Node       |             Index             |
125     |           |                  |                               |
126     +-----------+------------------+-------------------------------+
127@end group
128@end example
129@end ifset
130
131@ifset use-tex
132@sp 1
133@tex
134\centerline{\vbox{\offinterlineskip\halign{
135\strut#&
136\hbox to 0.50in{\enskip#}&
137\hbox to 0.50in{\enskip#}&
138#&
139\hbox to 0.50in{\enskip#}&
140\hbox to 0.50in{\enskip#}&
141#&
142\hbox to 1.00in{\enskip#}&
143\hbox to 1.00in{\enskip#}&
144#\cr
145\multispan{9}\cr
146\multispan{2}31\hfil&\multispan{2}\hfil26\enskip&
147 \multispan{1}\enskip25\hfil&\multispan{2}\hfil16\enskip&
148 \multispan{1}\enskip15\hfil&\multispan{2}\hfil0\cr
149&&&&&&&&&\cr
150}}\hfil}
151\centerline{\vbox{\offinterlineskip\halign{
152\strut\vrule#&
153\hbox to 0.50in{\enskip#}&
154\hbox to 0.50in{\enskip#}&
155\vrule#&
156\hbox to 0.50in{\enskip#}&
157\hbox to 0.50in{\enskip#}&
158\vrule#&
159\hbox to 0.50in{\enskip#}&
160\hbox to 0.50in{\enskip#}&
161\vrule#\cr
162\multispan{9}\cr
163\noalign{\hrule}
164&&&&&&&&&\cr
165&\multispan{2}\hfil Class\hfil&&
166 \multispan{2}\hfil Node\hfil&&
167 \multispan{2}\hfil Index\hfil&\cr
168&&&&&&&&&\cr
169\noalign{\hrule}
170}}\hfil}
171@end tex
172@end ifset
173
174@ifset use-html
175@html
176<CENTER>
177  <TABLE COLS=6 WIDTH="60%" BORDER=0>
178<TR><TD ALIGN=left><STRONG>31</STRONG></TD>
179    <TD ALIGN=right><STRONG>26</STRONG></TD>
180    <TD ALIGN=left><STRONG>25</STRONG></TD>
181    <TD ALIGN=right><STRONG>16</STRONG></TD>
182    <TD ALIGN=left><STRONG>15</STRONG></TD>
183    <TD ALIGN=right><STRONG>0</STRONG></TD></TR>
184  </TABLE>
185</CENTER>
186<CENTER>
187  <TABLE COLS=6 WIDTH="60%" BORDER=2>
188<TR><TD ALIGN=center COLSPAN=2>Class</TD>
189    <TD ALIGN=center COLSPAN=2>Node</TD>
190    <TD ALIGN=center COLSPAN=2>Index</TD></TD>
191  </TABLE>
192</CENTER>
193@end html
194@end ifset
195
196The most significant six bits are the object class.  The next
197ten bits are the number of the node on which this object was
198created.  The node number is always one (1) in a single
199processor system.  The least significant sixteen bits form an
200identifier within a particular object type.  This identifier,
201called the object index, ranges in value from 1 to the maximum
202number of objects configured for this object type.
203
204
205The three components of an object ID make it possible
206to quickly locate any object in even the most complicated
207multiprocessor system.  Object ID's are associated with an
208object by RTEMS when the object is created and the corresponding
209ID is returned by the appropriate object create directive.  The
210object ID is required as input to all directives involving
211objects, except those which create an object or obtain the ID of
212an object.
213
214The object identification directives can be used to
215dynamically obtain a particular object's ID given its name.
216This mapping is accomplished by searching the name table
217associated with this object type.  If the name is non-unique,
218then the ID associated with the first occurrence of the name
219will be returned to the application.  Since object IDs are
220returned when the object is created, the object identification
221directives are not necessary in a properly designed single
222processor application.
223
224In addition, services are provided to portably examine the
225three subcomponents of an RTEMS ID.  These services are
226prototyped as follows:
227
228@cindex obtaining class from object ID
229@cindex obtaining node from object ID
230@cindex obtaining index from object ID
231@cindex get class from object ID
232@cindex get node from object ID
233@cindex get index from object ID
234@findex rtems_get_class
235@findex rtems_get_node
236@findex rtems_get_index
237
238@example
239rtems_unsigned32 rtems_get_class( rtems_id );
240rtems_unsigned32 rtems_get_node( rtems_id );
241rtems_unsigned32 rtems_get_index( rtems_id );
242@end example
243
244An object control block is a data structure defined
245by RTEMS which contains the information necessary to manage a
246particular object type.  For efficiency reasons, the format of
247each object type's control block is different.  However, many of
248the fields are similar in function.  The number of each type of
249control block is application dependent and determined by the
250values specified in the user's Configuration Table.  An object
251control block is allocated at object create time and freed when
252the object is deleted.  With the exception of user extension
253routines, object control blocks are not directly manipulated by
254user applications.
255
256@section Communication and Synchronization
257
258@cindex communication and synchronization
259
260In real-time multitasking applications, the ability
261for cooperating execution threads to communicate and synchronize
262with each other is imperative.  A real-time executive should
263provide an application with the following capabilities:
264
265@itemize @bullet
266@item Data transfer between cooperating tasks
267@item Data transfer between tasks and ISRs
268@item Synchronization of cooperating tasks
269@item Synchronization of tasks and ISRs
270@end itemize
271
272Most RTEMS managers can be used to provide some form
273of communication and/or synchronization.  However, managers
274dedicated specifically to communication and synchronization
275provide well established mechanisms which directly map to the
276application's varying needs.  This level of flexibility allows
277the application designer to match the features of a particular
278manager with the complexity of communication and synchronization
279required.  The following managers were specifically designed for
280communication and synchronization:
281
282@itemize @bullet
283@item Semaphore
284@item Message Queue
285@item Event
286@item Signal
287@end itemize
288
289The semaphore manager supports mutual exclusion
290involving the synchronization of access to one or more shared
291user resources.  Binary semaphores may utilize the optional
292priority inheritance algorithm to avoid the problem of priority
293inversion.  The message manager supports both communication and
294synchronization, while the event manager primarily provides a
295high performance synchronization mechanism.  The signal manager
296supports only asynchronous communication and is typically used
297for exception handling.
298
299@section Time
300
301@cindex time
302
303The development of responsive real-time applications
304requires an understanding of how RTEMS maintains and supports
305time-related operations.  The basic unit of time in RTEMS is
306known as a tick.  The frequency of clock ticks is completely
307application dependent and determines the granularity and
308accuracy of all interval and calendar time operations.
309
310@findex rtems_interval
311
312By tracking time in units of ticks, RTEMS is capable
313of supporting interval timing functions such as task delays,
314timeouts, timeslicing, the delayed execution of timer service
315routines, and the rate monotonic scheduling of tasks.  An
316interval is defined as a number of ticks relative to the current
317time.  For example, when a task delays for an interval of ten
318ticks, it is implied that the task will not execute until ten
319clock ticks have occurred.
320All intervals are specified using data type
321@code{@value{DIRPREFIX}interval}.
322
323A characteristic of interval timing is that the
324actual interval period may be a fraction of a tick less than the
325interval requested.  This occurs because the time at which the
326delay timer is set up occurs at some time between two clock
327ticks.  Therefore, the first countdown tick occurs in less than
328the complete time interval for a tick.  This can be a problem if
329the clock granularity is large.
330
331The rate monotonic scheduling algorithm is a hard
332real-time scheduling methodology.  This methodology provides
333rules which allows one to guarantee that a set of independent
334periodic tasks will always meet their deadlines -- even under
335transient overload conditions.  The rate monotonic manager
336provides directives built upon the Clock Manager's interval
337timer support routines.
338
339Interval timing is not sufficient for the many
340applications which require that time be kept in wall time or
341true calendar form.  Consequently, RTEMS maintains the current
342date and time.  This allows selected time operations to be
343scheduled at an actual calendar date and time.  For example, a
344task could request to delay until midnight on New Year's Eve
345before lowering the ball at Times Square.
346The data type @code{@value{DIRPREFIX}time_of_day} is used to specify
347calendar time in RTEMS services. 
348@xref{Clock Manager Time and Date Data Structures, , Time and Date Data Structures}.
349@findex rtems_time_of_day
350
351Obviously, the directives which use intervals or wall
352time cannot operate without some external mechanism which
353provides a periodic clock tick.  This clock tick is typically
354provided by a real time clock or counter/timer device.
355
356@section Memory Management
357
358@cindex memory management
359
360RTEMS memory management facilities can be grouped
361into two classes: dynamic memory allocation and address
362translation.  Dynamic memory allocation is required by
363applications whose memory requirements vary through the
364application's course of execution.  Address translation is
365needed by applications which share memory with another CPU or an
366intelligent Input/Output processor.  The following RTEMS
367managers provide facilities to manage memory:
368
369@itemize @bullet
370@item Region
371
372@item Partition
373
374@item Dual Ported Memory
375@end itemize
376
377RTEMS memory management features allow an application
378to create simple memory pools of fixed size buffers and/or more
379complex memory pools of variable size segments.  The partition
380manager provides directives to manage and maintain pools of
381fixed size entities such as resource control blocks.
382Alternatively, the region manager provides a more general
383purpose memory allocation scheme that supports variable size
384blocks of memory which are dynamically obtained and freed by the
385application.  The dual-ported memory manager provides executive
386support for address translation between internal and external
387dual-ported RAM address space.
Note: See TracBrowser for help on using the repository browser.