source: rtems/doc/user/mp.t @ 0660b4f8

4.104.114.84.95
Last change on this file since 0660b4f8 was 0660b4f8, checked in by Joel Sherrill <joel.sherrill@…>, on 11/16/99 at 19:50:56

Changed copyright date to 1999.

  • Property mode set to 100644
File size: 21.6 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-1999.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6@c  $Id$
7@c
8
9@chapter Multiprocessing Manager
10
11@cindex multiprocessing
12
13@section Introduction
14
15In multiprocessor real-time systems, new
16requirements, such as sharing data and global resources between
17processors, are introduced.  This requires an efficient and
18reliable communications vehicle which allows all processors to
19communicate with each other as necessary.  In addition, the
20ramifications of multiple processors affect each and every
21characteristic of a real-time system, almost always making them
22more complicated.
23
24RTEMS addresses these issues by providing simple and
25flexible real-time multiprocessing capabilities.  The executive
26easily lends itself to both tightly-coupled and loosely-coupled
27configurations of the target system hardware.  In addition,
28RTEMS supports systems composed of both homogeneous and
29heterogeneous mixtures of processors and target boards.
30
31A major design goal of the RTEMS executive was to
32transcend the physical boundaries of the target hardware
33configuration.  This goal is achieved by presenting the
34application software with a logical view of the target system
35where the boundaries between processor nodes are transparent.
36As a result, the application developer may designate objects
37such as tasks, queues, events, signals, semaphores, and memory
38blocks as global objects.  These global objects may then be
39accessed by any task regardless of the physical location of the
40object and the accessing task.  RTEMS automatically determines
41that the object being accessed resides on another processor and
42performs the actions required to access the desired object.
43Simply stated, RTEMS allows the entire system, both hardware and
44software, to be viewed logically as a single system.
45
46@section Background
47
48@cindex multiprocessing topologies
49
50RTEMS makes no assumptions regarding the connection
51media or topology of a multiprocessor system.  The tasks which
52compose a particular application can be spread among as many
53processors as needed to satisfy the application's timing
54requirements.  The application tasks can interact using a subset
55of the RTEMS directives as if they were on the same processor.
56These directives allow application tasks to exchange data,
57communicate, and synchronize regardless of which processor they
58reside upon.
59
60The RTEMS multiprocessor execution model is multiple
61instruction streams with multiple data streams (MIMD).  This
62execution model has each of the processors executing code
63independent of the other processors.  Because of this
64parallelism, the application designer can more easily guarantee
65deterministic behavior.
66
67By supporting heterogeneous environments, RTEMS
68allows the systems designer to select the most efficient
69processor for each subsystem of the application.  Configuring
70RTEMS for a heterogeneous environment is no more difficult than
71for a homogeneous one.  In keeping with RTEMS philosophy of
72providing transparent physical node boundaries, the minimal
73heterogeneous processing required is isolated in the MPCI layer.
74
75@subsection Nodes
76
77@cindex nodes, definition
78
79A processor in a RTEMS system is referred to as a
80node.  Each node is assigned a unique non-zero node number by
81the application designer.  RTEMS assumes that node numbers are
82assigned consecutively from one to the @code{maximum_nodes}
83configuration parameter.  The node
84number, node, and the maximum number of nodes, maximum_nodes, in
85a system are found in the Multiprocessor Configuration Table.
86The maximum_nodes field and the number of global objects,
87maximum_global_objects, is required to be the same on all nodes
88in a system.
89
90The node number is used by RTEMS to identify each
91node when performing remote operations.  Thus, the
92Multiprocessor Communications Interface Layer (MPCI) must be
93able to route messages based on the node number.
94
95@subsection Global Objects
96
97@cindex global objects, definition
98
99All RTEMS objects which are created with the GLOBAL
100attribute will be known on all other nodes.  Global objects can
101be referenced from any node in the system, although certain
102directive specific restrictions (e.g. one cannot delete a remote
103object) may apply.  A task does not have to be global to perform
104operations involving remote objects.  The maximum number of
105global objects is the system is user configurable and can be
106found in the maximum_global_objects field in the Multiprocessor
107Configuration Table.  The distribution of tasks to processors is
108performed during the application design phase.  Dynamic task
109relocation is not supported by RTEMS.
110
111@subsection Global Object Table
112
113@cindex global objects table
114
115RTEMS maintains two tables containing object
116information on every node in a multiprocessor system: a local
117object table and a global object table.  The local object table
118on each node is unique and contains information for all objects
119created on this node whether those objects are local or global.
120The global object table contains information regarding all
121global objects in the system and, consequently, is the same on
122every node.
123
124Since each node must maintain an identical copy of
125the global object table,  the maximum number of entries in each
126copy of the table must be the same.  The maximum number of
127entries in each copy is determined by the
128maximum_global_objects parameter in the Multiprocessor
129Configuration Table.  This parameter, as well as the
130maximum_nodes parameter, is required to be the same on all
131nodes.  To maintain consistency among the table copies, every
132node in the system must be informed of the creation or deletion
133of a global object.
134
135@subsection Remote Operations
136
137@cindex MPCI and remote operations
138
139When an application performs an operation on a remote
140global object, RTEMS must generate a Remote Request (RQ) message
141and send it to the appropriate node.  After completing the
142requested operation, the remote node will build a Remote
143Response (RR) message and send it to the originating node.
144Messages generated as a side-effect of a directive (such as
145deleting a global task) are known as Remote Processes (RP) and
146do not require the receiving node to respond.
147
148Other than taking slightly longer to execute
149directives on remote objects, the application is unaware of the
150location of the objects it acts upon.  The exact amount of
151overhead required for a remote operation is dependent on the
152media connecting the nodes and, to a lesser degree, on the
153efficiency of the user-provided MPCI routines.
154
155The following shows the typical transaction sequence
156during a remote application:
157
158@enumerate
159
160@item The application issues a directive accessing a
161remote global object.
162
163@item RTEMS determines the node on which the object
164resides.
165
166@item RTEMS calls the user-provided MPCI routine
167GET_PACKET to obtain a packet in which to build a RQ message.
168
169@item After building a message packet, RTEMS calls the
170user-provided MPCI routine SEND_PACKET to transmit the packet to
171the node on which the object resides (referred to as the
172destination node).
173
174@item The calling task is blocked until the RR message
175arrives, and control of the processor is transferred to another
176task.
177
178@item The MPCI layer on the destination node senses the
179arrival of a packet (commonly in an ISR), and calls the
180@code{@value{DIRPREFIX}multiprocessing_announce}
181directive.  This directive readies the Multiprocessing Server.
182
183@item The Multiprocessing Server calls the user-provided
184MPCI routine RECEIVE_PACKET, performs the requested operation,
185builds an RR message, and returns it to the originating node.
186
187@item The MPCI layer on the originating node senses the
188arrival of a packet (typically via an interrupt), and calls the RTEMS
189@code{@value{DIRPREFIX}multiprocessing_announce} directive.  This directive
190readies the Multiprocessing Server.
191
192@item The Multiprocessing Server calls the user-provided
193MPCI routine RECEIVE_PACKET, readies the original requesting
194task, and blocks until another packet arrives.  Control is
195transferred to the original task which then completes processing
196of the directive.
197
198@end enumerate
199
200If an uncorrectable error occurs in the user-provided
201MPCI layer, the fatal error handler should be invoked.  RTEMS
202assumes the reliable transmission and reception of messages by
203the MPCI and makes no attempt to detect or correct errors.
204
205@subsection Proxies
206
207@cindex proxy, definition
208
209A proxy is an RTEMS data structure which resides on a
210remote node and is used to represent a task which must block as
211part of a remote operation. This action can occur as part of the
212@code{@value{DIRPREFIX}semaphore_obtain} and
213@code{@value{DIRPREFIX}message_queue_receive} directives.  If the
214object were local, the task's control block would be available
215for modification to indicate it was blocking on a message queue
216or semaphore.  However, the task's control block resides only on
217the same node as the task.  As a result, the remote node must
218allocate a proxy to represent the task until it can be readied.
219
220The maximum number of proxies is defined in the
221Multiprocessor Configuration Table.  Each node in a
222multiprocessor system may require a different number of proxies
223to be configured.  The distribution of proxy control blocks is
224application dependent and is different from the distribution of
225tasks.
226
227@subsection Multiprocessor Configuration Table
228
229The Multiprocessor Configuration Table contains
230information needed by RTEMS when used in a multiprocessor
231system.  This table is discussed in detail in the section
232Multiprocessor Configuration Table of the Configuring a System
233chapter.
234
235@section Multiprocessor Communications Interface Layer
236
237The Multiprocessor Communications Interface Layer
238(MPCI) is a set of user-provided procedures which enable the
239nodes in a multiprocessor system to communicate with one
240another.  These routines are invoked by RTEMS at various times
241in the preparation and processing of remote requests.
242Interrupts are enabled when an MPCI procedure is invoked.  It is
243assumed that if the execution mode and/or interrupt level are
244altered by the MPCI layer, that they will be restored prior to
245returning to RTEMS.
246
247@cindex MPCI, definition
248
249The MPCI layer is responsible for managing a pool of
250buffers called packets and for sending these packets between
251system nodes.  Packet buffers contain the messages sent between
252the nodes.  Typically, the MPCI layer will encapsulate the
253packet within an envelope which contains the information needed
254by the MPCI layer.  The number of packets available is dependent
255on the MPCI layer implementation.
256
257@cindex MPCI entry points
258
259The entry points to the routines in the user's MPCI
260layer should be placed in the Multiprocessor Communications
261Interface Table.  The user must provide entry points for each of
262the following table entries in a multiprocessor system:
263
264@itemize @bullet
265@item initialization    initialize the MPCI
266@item get_packet        obtain a packet buffer
267@item return_packet     return a packet buffer
268@item send_packet       send a packet to another node
269@item receive_packet    called to get an arrived packet
270@end itemize
271
272A packet is sent by RTEMS in each of the following situations:
273
274@itemize @bullet
275@item an RQ is generated on an originating node;
276@item an RR is generated on a destination node;
277@item a global object is created;
278@item a global object is deleted;
279@item a local task blocked on a remote object is deleted;
280@item during system initialization to check for system consistency.
281@end itemize
282
283If the target hardware supports it, the arrival of a
284packet at a node may generate an interrupt.  Otherwise, the
285real-time clock ISR can check for the arrival of a packet.  In
286any case, the
287@code{@value{DIRPREFIX}multiprocessing_announce} directive must be called
288to announce the arrival of a packet.  After exiting the ISR,
289control will be passed to the Multiprocessing Server to process
290the packet.  The Multiprocessing Server will call the get_packet
291entry to obtain a packet buffer and the receive_entry entry to
292copy the message into the buffer obtained.
293
294@subsection INITIALIZATION
295
296The INITIALIZATION component of the user-provided
297MPCI layer is called as part of the @code{@value{DIRPREFIX}initialize_executive}
298directive to initialize the MPCI layer and associated hardware.
299It is invoked immediately after all of the device drivers have
300been initialized.  This component should be adhere to the
301following prototype:
302
303@ifset is-C
304@example
305@group
306rtems_mpci_entry user_mpci_initialization(
307  rtems_configuration_table *configuration
308);
309@end group
310@end example
311@end ifset
312
313@ifset is-Ada
314@example
315procedure User_MPCI_Initialization (
316   Configuration : in     RTEMS.Configuration_Table_Pointer
317);
318@end example
319@end ifset
320
321where configuration is the address of the user's
322Configuration Table.  Operations on global objects cannot be
323performed until this component is invoked.  The INITIALIZATION
324component is invoked only once in the life of any system.  If
325the MPCI layer cannot be successfully initialized, the fatal
326error manager should be invoked by this routine.
327
328One of the primary functions of the MPCI layer is to
329provide the executive with packet buffers.  The INITIALIZATION
330routine must create and initialize a pool of packet buffers.
331There must be enough packet buffers so RTEMS can obtain one
332whenever needed.
333
334@subsection GET_PACKET
335
336The GET_PACKET component of the user-provided MPCI
337layer is called when RTEMS must obtain a packet buffer to send
338or broadcast a message.  This component should be adhere to the
339following prototype:
340
341@ifset is-C
342@example
343@group
344rtems_mpci_entry user_mpci_get_packet(
345  rtems_packet_prefix **packet
346);
347@end group
348@end example
349@end ifset
350
351@ifset is-Ada
352@example
353procedure User_MPCI_Get_Packet (
354   Packet : access RTEMS.Packet_Prefix_Pointer
355);
356@end example
357@end ifset
358
359where packet is the address of a pointer to a packet.
360This routine always succeeds and, upon return, packet will
361contain the address of a packet.  If for any reason, a packet
362cannot be successfully obtained, then the fatal error manager
363should be invoked.
364
365RTEMS has been optimized to avoid the need for
366obtaining a packet each time a message is sent or broadcast.
367For example, RTEMS sends response messages (RR) back to the
368originator in the same packet in which the request message (RQ)
369arrived.
370
371@subsection RETURN_PACKET
372
373The RETURN_PACKET component of the user-provided MPCI
374layer is called when RTEMS needs to release a packet to the free
375packet buffer pool.  This component should be adhere to the
376following prototype:
377
378@ifset is-C
379@example
380@group
381rtems_mpci_entry user_mpci_return_packet(
382  rtems_packet_prefix *packet
383);
384@end group
385@end example
386@end ifset
387
388@ifset is-Ada
389@example
390procedure User_MPCI_Return_Packet (
391   Packet : in     RTEMS.Packet_Prefix_Pointer
392);
393@end example
394@end ifset
395
396where packet is the address of a packet.  If the
397packet cannot be successfully returned, the fatal error manager
398should be invoked.
399
400@subsection RECEIVE_PACKET
401
402The RECEIVE_PACKET component of the user-provided
403MPCI layer is called when RTEMS needs to obtain a packet which
404has previously arrived.  This component should be adhere to the
405following prototype:
406
407@ifset is-C
408@example
409@group
410rtems_mpci_entry user_mpci_receive_packet(
411  rtems_packet_prefix **packet
412);
413@end group
414@end example
415@end ifset
416
417@ifset is-Ada
418@example
419procedure User_MPCI_Receive_Packet (
420   Packet : access RTEMS.Packet_Prefix_Pointer
421);
422@end example
423@end ifset
424
425where packet is a pointer to the address of a packet
426to place the message from another node.  If a message is
427available, then packet will contain the address of the message
428from another node.  If no messages are available, this entry
429packet should contain NULL.
430
431@subsection SEND_PACKET
432
433The SEND_PACKET component of the user-provided MPCI
434layer is called when RTEMS needs to send a packet containing a
435message to another node.  This component should be adhere to the
436following prototype:
437
438@ifset is-C
439@example
440@group
441rtems_mpci_entry user_mpci_send_packet(
442  rtems_unsigned32       node,
443  rtems_packet_prefix  **packet
444);
445@end group
446@end example
447@end ifset
448
449@ifset is-Ada
450@example
451procedure User_MPCI_Send_Packet (
452   Node   : in     RTEMS.Unsigned32;
453   Packet : access RTEMS.Packet_Prefix_Pointer
454);
455@end example
456@end ifset
457
458where node is the node number of the destination and packet is the
459address of a packet which containing a message.  If the packet cannot
460be successfully sent, the fatal error manager should be invoked.
461
462If node is set to zero, the packet is to be
463broadcasted to all other nodes in the system.  Although some
464MPCI layers will be built upon hardware which support a
465broadcast mechanism, others may be required to generate a copy
466of the packet for each node in the system.
467
468Many MPCI layers use the packet_length field of the MP_packet_prefix
469of the packet to avoid sending unnecessary data.  This is especially
470useful if the media connecting the nodes is relatively slow.
471
472The to_convert field of the MP_packet_prefix portion of the packet indicates
473how much of the packet (in unsigned32's) may require conversion in a
474heterogeneous system.
475
476@subsection Supporting Heterogeneous Environments
477
478@cindex heterogeneous multiprocessing
479
480Developing an MPCI layer for a heterogeneous system
481requires a thorough understanding of the differences between the
482processors which comprise the system.  One difficult problem is
483the varying data representation schemes used by different
484processor types.  The most pervasive data representation problem
485is the order of the bytes which compose a data entity.
486Processors which place the least significant byte at the
487smallest address are classified as little endian processors.
488Little endian byte-ordering is shown below:
489
490
491@example
492@group
493+---------------+----------------+---------------+----------------+
494|               |                |               |                |
495|    Byte 3     |     Byte 2     |    Byte 1     |    Byte 0      |
496|               |                |               |                |
497+---------------+----------------+---------------+----------------+
498@end group
499@end example
500
501Conversely, processors which place the most
502significant byte at the smallest address are classified as big
503endian processors.  Big endian byte-ordering is shown below:
504
505@example
506@group
507+---------------+----------------+---------------+----------------+
508|               |                |               |                |
509|    Byte 0     |     Byte 1     |    Byte 2     |    Byte 3      |
510|               |                |               |                |
511+---------------+----------------+---------------+----------------+
512@end group
513@end example
514
515Unfortunately, sharing a data structure between big
516endian and little endian processors requires translation into a
517common endian format.  An application designer typically chooses
518the common endian format to minimize conversion overhead.
519
520Another issue in the design of shared data structures
521is the alignment of data structure elements.  Alignment is both
522processor and compiler implementation dependent.  For example,
523some processors allow data elements to begin on any address
524boundary, while others impose restrictions.  Common restrictions
525are that data elements must begin on either an even address or
526on a long word boundary.  Violation of these restrictions may
527cause an exception or impose a performance penalty.
528
529Other issues which commonly impact the design of
530shared data structures include the representation of floating
531point numbers, bit fields, decimal data, and character strings.
532In addition, the representation method for negative integers
533could be one's or two's complement.  These factors combine to
534increase the complexity of designing and manipulating data
535structures shared between processors.
536
537RTEMS addressed these issues in the design of the
538packets used to communicate between nodes.  The RTEMS packet
539format is designed to allow the MPCI layer to perform all
540necessary conversion without burdening the developer with the
541details of the RTEMS packet format.  As a result, the MPCI layer
542must be aware of the following:
543
544@itemize @bullet
545@item All packets must begin on a four byte boundary.
546
547@item Packets are composed of both RTEMS and application data.
548All RTEMS data is treated as thirty-two (32) bit unsigned
549quantities and is in the first @code{@value{RPREFIX}MINIMUM_UNSIGNED32S_TO_CONVERT}
550thirty-two (32) quantities of the packet.
551
552@item The RTEMS data component of the packet must be in native
553endian format.  Endian conversion may be performed by either the
554sending or receiving MPCI layer.
555
556@item RTEMS makes no assumptions regarding the application
557data component of the packet.
558@end itemize
559
560@section Operations
561
562@subsection Announcing a Packet
563
564The @code{@value{DIRPREFIX}multiprocessing_announce} directive is called by
565the MPCI layer to inform RTEMS that a packet has arrived from
566another node.  This directive can be called from an interrupt
567service routine or from within a polling routine.
568
569@section Directives
570
571This section details the additional directives
572required to support RTEMS in a multiprocessor configuration.  A
573subsection is dedicated to each of this manager's directives and
574describes the calling sequence, related constants, usage, and
575status codes.
576
577@c
578@c
579@c
580@page
581@subsection MULTIPROCESSING_ANNOUNCE - Announce the arrival of a packet
582
583@cindex announce arrival of package
584
585@subheading CALLING SEQUENCE:
586
587@ifset is-C
588@findex rtems_multiprocessing_announce
589@example
590void rtems_multiprocessing_announce( void );
591@end example
592@end ifset
593
594@ifset is-Ada
595@example
596procedure Multiprocessing_Announce;
597@end example
598@end ifset
599
600@subheading DIRECTIVE STATUS CODES:
601
602NONE
603
604@subheading DESCRIPTION:
605
606This directive informs RTEMS that a multiprocessing
607communications packet has arrived from another node.  This
608directive is called by the user-provided MPCI, and is only used
609in multiprocessor configurations.
610
611@subheading NOTES:
612
613This directive is typically called from an ISR.
614
615This directive will almost certainly cause the
616calling task to be preempted.
617
618This directive does not generate activity on remote nodes.
Note: See TracBrowser for help on using the repository browser.