Microsoft KB Archive/297347

= PRB: Random Exceptions or System Lockup on PowerPC Platform ISR Under Heavy Interrupt Load =

Article ID: 297347

Article Last Modified on 1/31/2007

-

APPLIES TO


 * Microsoft Windows CE Platform Builder 2.11
 * Microsoft Windows CE Platform Builder 2.12
 * Microsoft Encarta Reference Suite 2001

-



This article was previously published under Q297347



SYMPTOMS
When you are using a PowerPC OEM adaptation layer (OAL) developed with Platform Builder 3.0, random exceptions and system lockups may occur centering around the OAL Interrupt Service Routine (ISR).



CAUSE
In the PowerPC ISR, it is possible for unguarded atomic operations to be corrupted. The result is a probable incidence of random exceptions and system lockups.



RESOLUTION
To resolve this problem, you can use the &quot;Load Word and Reserve indeXed&quot; (lwarx) and &quot;STore Word Conditional indeXed&quot; (stwcx) conditional load/store instructions with the proper looping logic to guarantee data integrity against reentrancy.



STATUS
This behavior is by design.



MORE INFORMATION
The PowerPC does not have a way to perform strict atomic operations intrinsically guarded by the processor. Instead, the PowerPC provides the lwarx and stwcx instructions to provide a mechanism for guarding against interrupted atomic memory operations. These are intended to allow the programmer to load a value from memory, execute other code, and then conditionally store the value back to the same memory address. The processor will only perform the store if no other stores have occurred to the same address since the first load, otherwise this will fail. If the store fails, the RESERVED bit will be cleared. The code can use a loop to test the RESERVED bit and, if clear, retry the load/store operation again until the conditional store succeeds. If the ISR is reentered or memory touched in the ISR is otherwise written to out of sequence with the ISR, this lwarx/stcwx logic will cause the operation to try until it gets a clean atomic load/store. For example, loop: li r5, g_Value lwarx  r4, r0, r5 addi    r4, r4, SOME_NUMBER stwcx. r4, r0, r5 bne loop

As an example, this logic is performed in the source for the ODO [Hitachi D9000 hardware development platform] PowerPC OAL in the Platform Builder 3.0 under \WINCE300\PLATFORM\ODO\KERNEL\HAL\PPC\intr403.s for the CurMSecUpdate and DiffMSecUpdate operations. See the design manuals for your processor for details on how these instructions work.

The third-party products that are discussed in this article are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.

Keywords: kbnofix kbprb KB297347

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.