05.02.2013 Views

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The System Level Programmers’ Model<br />

If the processor cannot obtain the lock, it reads the lock value repeatedly in a tight loop until the lock<br />

becomes available. At this point it again attempts to obtain the lock.<br />

However, this spin-lock mechanism is not ideal for all situations:<br />

in a low-power system the tight read loop is undesirable because it uses energy to no effect<br />

in a multi-threaded processor the execution of spin-locks by waiting threads can significantly degrade<br />

overall performance.<br />

Therefore, <strong>ARM</strong>v7 provides an alternative locking mechanism based on events. The Wait For Event lock<br />

mechanism permits a processor that has failed to obtain a lock to enter a low-power state. When the<br />

processor that currently holds the required lock releases the lock it sends an event that causes any waiting<br />

processors to wake up <strong>and</strong> attempt to gain the lock again.<br />

Note<br />

Although a complex operating system can contain thous<strong>and</strong>s of distinct locks, the event sent by this<br />

mechanism does not indicate which lock has been released. If the event relates to a different lock, or if<br />

another processor acquires the lock more quickly, the processor fails to acquire the lock <strong>and</strong> can re-enter the<br />

low-power state waiting for the next event.<br />

The Wait For Event system relies on hardware <strong>and</strong> software working together to achieve energy saving:<br />

the hardware provides the mechanism to enter the Wait For Event low-power state<br />

the operating system software is responsible for issuing:<br />

— a Wait For Event instruction when waiting for a spin-lock, to enter the low-power state<br />

— a Send Event instructions when releasing a spin-lock.<br />

The mechanism depends on the interaction of:<br />

WFE wake-up events, see WFE wake-up events<br />

the Event Register, see The Event Register on page B1-46<br />

the Send Event instruction, see The Send Event instruction on page B1-46<br />

the Wait For Event instruction, see The Wait For Event instruction on page B1-46.<br />

WFE wake-up events<br />

The following events are WFE wake-up events:<br />

the execution of an SEV instruction on any processor in the multiprocessor system<br />

an IRQ interrupt, unless masked by the CPSR.I bit<br />

an FIQ interrupt, unless masked by the CPSR.F bit<br />

an asynchronous abort, unless masked by the CPSR.A bit<br />

a debug event, if invasive debug is enabled <strong>and</strong> the debug event is permitted.<br />

For details of the masking bits in the CPSR see Format of the CPSR <strong>and</strong> SPSRs on page B1-16. This<br />

masking is an important consideration with this mechanism, because lock mechanisms can be required<br />

when interrupts are disabled.<br />

<strong>ARM</strong> DDI 0406B Copyright © 1996-1998, 2000, 2004-2008 <strong>ARM</strong> Limited. All rights reserved. B1-45

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!