source: rtems/doc/user/mp.t @ 6449498

4.104.114.84.95
Last change on this file since 6449498 was 6449498, checked in by Joel Sherrill <joel.sherrill@…>, on 01/17/02 at 21:47:47

2001-01-17 Joel Sherrill <joel@…>

  • SUPPORT, LICENSE: New files.
  • Numerous files touched as part of merging the 4.5 branch onto the mainline development trunk and ensuring that the script that cuts snapshots and releases works on the documentation.
  • Property mode set to 100644
File size: 21.8 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 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@findex rtems_mpci_entry
305@example
306@group
307rtems_mpci_entry user_mpci_initialization(
308  rtems_configuration_table *configuration
309);
310@end group
311@end example
312@end ifset
313
314@ifset is-Ada
315@example
316procedure User_MPCI_Initialization (
317   Configuration : in     RTEMS.Configuration_Table_Pointer
318);
319@end example
320@end ifset
321
322where configuration is the address of the user's
323Configuration Table.  Operations on global objects cannot be
324performed until this component is invoked.  The INITIALIZATION
325component is invoked only once in the life of any system.  If
326the MPCI layer cannot be successfully initialized, the fatal
327error manager should be invoked by this routine.
328
329One of the primary functions of the MPCI layer is to
330provide the executive with packet buffers.  The INITIALIZATION
331routine must create and initialize a pool of packet buffers.
332There must be enough packet buffers so RTEMS can obtain one
333whenever needed.
334
335@subsection GET_PACKET
336
337The GET_PACKET component of the user-provided MPCI
338layer is called when RTEMS must obtain a packet buffer to send
339or broadcast a message.  This component should be adhere to the
340following prototype:
341
342@ifset is-C
343@example
344@group
345rtems_mpci_entry user_mpci_get_packet(
346  rtems_packet_prefix **packet
347);
348@end group
349@end example
350@end ifset
351
352@ifset is-Ada
353@example
354procedure User_MPCI_Get_Packet (
355   Packet : access RTEMS.Packet_Prefix_Pointer
356);
357@end example
358@end ifset
359
360where packet is the address of a pointer to a packet.
361This routine always succeeds and, upon return, packet will
362contain the address of a packet.  If for any reason, a packet
363cannot be successfully obtained, then the fatal error manager
364should be invoked.
365
366RTEMS has been optimized to avoid the need for
367obtaining a packet each time a message is sent or broadcast.
368For example, RTEMS sends response messages (RR) back to the
369originator in the same packet in which the request message (RQ)
370arrived.
371
372@subsection RETURN_PACKET
373
374The RETURN_PACKET component of the user-provided MPCI
375layer is called when RTEMS needs to release a packet to the free
376packet buffer pool.  This component should be adhere to the
377following prototype:
378
379@ifset is-C
380@example
381@group
382rtems_mpci_entry user_mpci_return_packet(
383  rtems_packet_prefix *packet
384);
385@end group
386@end example
387@end ifset
388
389@ifset is-Ada
390@example
391procedure User_MPCI_Return_Packet (
392   Packet : in     RTEMS.Packet_Prefix_Pointer
393);
394@end example
395@end ifset
396
397where packet is the address of a packet.  If the
398packet cannot be successfully returned, the fatal error manager
399should be invoked.
400
401@subsection RECEIVE_PACKET
402
403The RECEIVE_PACKET component of the user-provided
404MPCI layer is called when RTEMS needs to obtain a packet which
405has previously arrived.  This component should be adhere to the
406following prototype:
407
408@ifset is-C
409@example
410@group
411rtems_mpci_entry user_mpci_receive_packet(
412  rtems_packet_prefix **packet
413);
414@end group
415@end example
416@end ifset
417
418@ifset is-Ada
419@example
420procedure User_MPCI_Receive_Packet (
421   Packet : access RTEMS.Packet_Prefix_Pointer
422);
423@end example
424@end ifset
425
426where packet is a pointer to the address of a packet
427to place the message from another node.  If a message is
428available, then packet will contain the address of the message
429from another node.  If no messages are available, this entry
430packet should contain NULL.
431
432@subsection SEND_PACKET
433
434The SEND_PACKET component of the user-provided MPCI
435layer is called when RTEMS needs to send a packet containing a
436message to another node.  This component should be adhere to the
437following prototype:
438
439@ifset is-C
440@example
441@group
442rtems_mpci_entry user_mpci_send_packet(
443  rtems_unsigned32       node,
444  rtems_packet_prefix  **packet
445);
446@end group
447@end example
448@end ifset
449
450@ifset is-Ada
451@example
452procedure User_MPCI_Send_Packet (
453   Node   : in     RTEMS.Unsigned32;
454   Packet : access RTEMS.Packet_Prefix_Pointer
455);
456@end example
457@end ifset
458
459where node is the node number of the destination and packet is the
460address of a packet which containing a message.  If the packet cannot
461be successfully sent, the fatal error manager should be invoked.
462
463If node is set to zero, the packet is to be
464broadcasted to all other nodes in the system.  Although some
465MPCI layers will be built upon hardware which support a
466broadcast mechanism, others may be required to generate a copy
467of the packet for each node in the system.
468
469@c XXX packet_prefix structure needs to be defined in this document
470Many MPCI layers use the @code{packet_length} field of the
471@code{@value{DIRPREFIX}packet_prefix} portion
472of the packet to avoid sending unnecessary data.  This is especially
473useful if the media connecting the nodes is relatively slow.
474
475The to_convert field of the MP_packet_prefix portion of the packet indicates
476how much of the packet (in @code{@value{DIRPREFIX}unsigned32}'s) may require
477conversion in a heterogeneous system.
478
479@subsection Supporting Heterogeneous Environments
480
481@cindex heterogeneous multiprocessing
482
483Developing an MPCI layer for a heterogeneous system
484requires a thorough understanding of the differences between the
485processors which comprise the system.  One difficult problem is
486the varying data representation schemes used by different
487processor types.  The most pervasive data representation problem
488is the order of the bytes which compose a data entity.
489Processors which place the least significant byte at the
490smallest address are classified as little endian processors.
491Little endian byte-ordering is shown below:
492
493
494@example
495@group
496+---------------+----------------+---------------+----------------+
497|               |                |               |                |
498|    Byte 3     |     Byte 2     |    Byte 1     |    Byte 0      |
499|               |                |               |                |
500+---------------+----------------+---------------+----------------+
501@end group
502@end example
503
504Conversely, processors which place the most
505significant byte at the smallest address are classified as big
506endian processors.  Big endian byte-ordering is shown below:
507
508@example
509@group
510+---------------+----------------+---------------+----------------+
511|               |                |               |                |
512|    Byte 0     |     Byte 1     |    Byte 2     |    Byte 3      |
513|               |                |               |                |
514+---------------+----------------+---------------+----------------+
515@end group
516@end example
517
518Unfortunately, sharing a data structure between big
519endian and little endian processors requires translation into a
520common endian format.  An application designer typically chooses
521the common endian format to minimize conversion overhead.
522
523Another issue in the design of shared data structures
524is the alignment of data structure elements.  Alignment is both
525processor and compiler implementation dependent.  For example,
526some processors allow data elements to begin on any address
527boundary, while others impose restrictions.  Common restrictions
528are that data elements must begin on either an even address or
529on a long word boundary.  Violation of these restrictions may
530cause an exception or impose a performance penalty.
531
532Other issues which commonly impact the design of
533shared data structures include the representation of floating
534point numbers, bit fields, decimal data, and character strings.
535In addition, the representation method for negative integers
536could be one's or two's complement.  These factors combine to
537increase the complexity of designing and manipulating data
538structures shared between processors.
539
540RTEMS addressed these issues in the design of the
541packets used to communicate between nodes.  The RTEMS packet
542format is designed to allow the MPCI layer to perform all
543necessary conversion without burdening the developer with the
544details of the RTEMS packet format.  As a result, the MPCI layer
545must be aware of the following:
546
547@itemize @bullet
548@item All packets must begin on a four byte boundary.
549
550@item Packets are composed of both RTEMS and application data.
551All RTEMS data is treated as thirty-two (32) bit unsigned
552quantities and is in the first @code{@value{RPREFIX}MINIMUM_UNSIGNED32S_TO_CONVERT}
553thirty-two (32) quantities of the packet.
554
555@item The RTEMS data component of the packet must be in native
556endian format.  Endian conversion may be performed by either the
557sending or receiving MPCI layer.
558
559@item RTEMS makes no assumptions regarding the application
560data component of the packet.
561@end itemize
562
563@section Operations
564
565@subsection Announcing a Packet
566
567The @code{@value{DIRPREFIX}multiprocessing_announce} directive is called by
568the MPCI layer to inform RTEMS that a packet has arrived from
569another node.  This directive can be called from an interrupt
570service routine or from within a polling routine.
571
572@section Directives
573
574This section details the additional directives
575required to support RTEMS in a multiprocessor configuration.  A
576subsection is dedicated to each of this manager's directives and
577describes the calling sequence, related constants, usage, and
578status codes.
579
580@c
581@c
582@c
583@page
584@subsection MULTIPROCESSING_ANNOUNCE - Announce the arrival of a packet
585
586@cindex announce arrival of package
587
588@subheading CALLING SEQUENCE:
589
590@ifset is-C
591@findex rtems_multiprocessing_announce
592@example
593void rtems_multiprocessing_announce( void );
594@end example
595@end ifset
596
597@ifset is-Ada
598@example
599procedure Multiprocessing_Announce;
600@end example
601@end ifset
602
603@subheading DIRECTIVE STATUS CODES:
604
605NONE
606
607@subheading DESCRIPTION:
608
609This directive informs RTEMS that a multiprocessing
610communications packet has arrived from another node.  This
611directive is called by the user-provided MPCI, and is only used
612in multiprocessor configurations.
613
614@subheading NOTES:
615
616This directive is typically called from an ISR.
617
618This directive will almost certainly cause the
619calling task to be preempted.
620
621This directive does not generate activity on remote nodes.
Note: See TracBrowser for help on using the repository browser.