• Aucun résultat trouvé

Storage Synchronization Instructions

Dans le document BUSl, ~ESS (Page 111-115)

3.3 Fixed-Point Processor Instructions

3.3.7 Storage Synchronization Instructions

The Storage Synchronization instructions can be used to control the order in which storage operations are completed with respect to asynchronous events, and the order in which storage operations are seen by other pro-cessors and by other mechanisms that access storage. Additional informa-tion about these instrucinforma-tions and about related aspects of storage management can be found in Book II, Sections 1.8.1, "Storage Access Ordering," on page 333 and 1.8.2, "Atomic Update Primitives," on page 336, and Book III, Chapter 4, "Storage Control," on page 391.

On a PowerPC system operating with Little-Endian byte order the three low-order bits of the effective address computed by Load And Reserve and Store Conditional are modified before accessing storage. See Appendix D, "Little-Endian Byte Ordering," on page 233.

Load Word And Reserve Indexed X-form

lwarx RT,RA,RB Condi-tional instruction. An address computed from the EA is associated with the reservation and replaces any address previously associated with the reservation: the manner in which the address to be associated with the reservation is computed from the EA is described in Book II, Section 1.8.2, "Atomic Update Primitives," on page 336.

EA must be a multiple of 4. If it is not, either the system alignment error handler is invoked or the results are boundedly undefined.

Special Registers Altered None

Load Doubleword And Reserve Indexed X-form

ldarx RT,RA,RB provide system library programs that use these instructions to implement rather than use the Storage Synchronization accessed by the Load And Reserve and Store Conditional instructions should be allocated by a system library program.

Additional information can be found in Book II, Section 1.8.2, "Atomic Update Primitives," on

Programming Note When correctly used, the Load And Reserve and Store Conditional instructions can provide an atomic update function for a single aligned word (Load Word And Reserve and Store Word Conditional) or

One of the requirements for correct use is that Load Word And Reserve be paired with Store Word Conditional, and Load Double Word And Reserve with Store Doubleword Conditional, with the same effective address used for both instructions of the pair.

Examples of correct uses of these instructions to emulate primitives such as "Fetch and Add," "Test and Set," and "Compare and Swap" can be found in Appendix E.1,

"Synchronization," on page 249.

At most one reservation exists on any given processor: there are not separate reservations for words and for

doublewords.

The conditionality of the Store Conditional instruction's store is based only on whether a

Let the effective address (EA) be the sum (RAIO)+(RB). The double-word in storage addressed by EA is loaded into RT.

This instruction creates a reservation for use by a Store Doubleword Conditional instruction. An address computed from the EA is associated with the reservation and replaces any address previously associated with the reservation: the manner in which the address to be associated with the reservation is computed from the EA is described in Book II, Section 1.8.2, "Atomic Update Primitives," on page 336.

EA must be a multiple of 8. If it is not, either the system alignment error handler is invoked or the results are boundedly undefined.

This instruction is defined only for 64-bit implementations. Using it on a 32-bit implementation will cause the system illegal instruction error handler to be invoked.

Special Registers Altered None

Store Word Conditional Indexed X-form

stwcx. RS,RA,RB

Let the effective address (EA) be the sum (RAIO)+(RB).

150

If a reservation exists, (RSl32:63 are stored into the word in storage addressed by EA and the reservation is cleared.

If a reservation does not exist, the instruction completes without alter-ing storage.

CR Field 0 is set to reflect whether the store operation was performed (i.e., whether a reservation existed when the stwcx. instruction com-menced execution), as follows.

CROLT GT EQ so= ObOO II store_performed II XERso

EA must be a multiple of 4. If it is not, either the system alignment error handler is invoked or the results are boundedly undefined.

Special Registers Altered CRO

Store Doubleword Conditional Indexed X-form

stdcx. RS,RA,RB addressed by EA and the reservation is cleared.

If a reservation does not exist, the instruction completes without alter-ing storage.

CR Field 0 is set to reflect whether the store operation was performed (i.e., whether a reservation existed when the stdcx. instruction com-menced execution), as follows.

CROLT GT EQ

so

= ObOO II store_performed II XERso

EA must be a multiple of 8. If it is not, either the system alignment error handler is invoked or the results are boundedly undefined.

This instruction is defined only for 64-bit implementations. Using it on a 32-bit implementation will cause the system illegal instruction error handler to be invoked.

Special Registers Altered CRO

reservation exists, not on a match between the address associated with the reservation and the address computed from the EA of the Store Conditional instruction.

A reservation is cleared if any of the following events occurs.

• The processor holding the reservation executes another Load And Reserve

instruction; this clears the first reservation and establishes a new one.

• The processor holding the reservation executes a Store Conditional instruction to any address.

• Another processor executes any Store Primitives," on page 336 for additional

information.

Programming Note The sync instruction can be used to ensure that the results of all stores into a data structure that are performed in a

"critical section" of a program are seen by other processors before the data structure is seen as unlocked.

The functions performed by the sync instruction will normally take a significant amount of time to complete, so indiscriminate use of this instruction may adversely affect performance. In addition, the time required to execute sync may vary from one execution to another.

The Enforce In-order Execution of 110 (eieio) instruction, described in Book II, Sections 1.8.1,

"Storage Access Ordering," on page 333 and 3.3, "Enforce In-order Execution of 1/0 Instruction," on page 350 may be more appropriate than sync for cases in which the only requirement is to control the order in which storage references are seen by 1/0 devices.

Synchronize X-form sync

[Power mnemonic: des]

31 Ill 1

11 Ill

I

16 Ill 598

The sync instruction provides an ordering function for the effects of all instructions executed by a given processor. Executing a sync instruction ensures that all instructions previously initiated by the given processor appear to have completed before the sync instruction completes, and that no subsequent instructions are initiated by the given processor until after the sync instruction completes. When the sync instruction completes, all storage aci:esses initiated by the given processor prior to the sync instruc-tion will have been performed with respect to all other mechanisms that access storage. (See Book II, "Synchronize," on page 334 for a more complete description. See also Book III, Section 4.12, "Table Update Syn-chronization Requirements," on page 446 for an exception involving TLB invalidates.)

This instruction is execution synchronizing (see Book III, Section 1.7.2, "Execution Synchronization," on page 372).

Special Registers Altered None

Dans le document BUSl, ~ESS (Page 111-115)