ARM MPCore -- (2)
NOP不一定會占用CPU執行時間,可能在執行該指令前,CPU已將其從管道中移除。
本文引用地址:http://www.104case.com/article/201611/317204.htm可以用NOP進行填充,使后續指令處于64bit邊界上。
2. SEV
向所有CPU Core發送事件信息。
3. WFE (Wait For Event)
如果未設置事件寄存器,則 WFE 會暫時中斷掛起執行,直至發生任一以下事件后再恢復執行:
(1)發生 IRQ 中斷,除非被 CPSR I 位屏蔽
(2)發生 FIQ 中斷,除非被 CPSR F 位屏蔽
(3)發生不精確的數據中止,除非被 CPSR A 位屏蔽
(4)出現調試進入請求(需啟用調試)
(5)另一個處理器利用 SEV 指令向事件發送信號
----------------------------
如果設置了事件寄存器,則 WFE 會清除該設置,然后立即返回。
如果實現了 WFE,則還必須實現 SEV。
4. WFI (Wait For Interrupt)
WFI 會暫時將執行中斷掛起,直至發生以下事件后再恢復執行:
(1)發生 IRQ 中斷,不考慮 CPSR I 位
(2)發生 FIQ 中斷,不考慮 CPSR F 位
(3)發生不精確的數據中止,除非被 CPSR A 位屏蔽
(4)出現調試進入請求,無論是否啟用調試
5. SEV/WFE用處
SEV/WFE are not intended for synchronisation- but for power management. Because of the way WFE is defined, there is no guarantee that the CPU1 will only awake when CPU0 executes SEV. It could wake at time for any number of reasons. Usually examples show SEV/WFE as a form of simple power management in a spin-lock. Something like:
lock_spin_lock (assume addr in r0)
LDREX r1, [r0]
CMP r1, #UNLOCKED
WFENE ; If not unlocked go to sleep
BNE lock_spin_lock ; on waking, re-check the spin-lock
...
Its the spin-lcok that provides the synchronisation, not the WFE. The WFE just is a way of saving power while you wait for the resource to become free
評論