Spinlock implementation in ARM architecture
Spinlock implementation in ARM architecture
SEV
WFE
If the Event Register is not set, WFE suspends execution until one of the following events occurs:
- an IRQ interrupt, unless masked by the CPSR I-bit
- an FIQ interrupt, unless masked by the CPSR F-bit
- an Imprecise Data abort, unless masked by the CPSR A-bit
- a Debug Entry request, if Debug is enabled
- an Event signaled by another processor using the SEV instruction.
In case of spin_lock_irq( )/spin_lock_irqsave( ),
- as IRQs are disabled, the only way to to resume after WFE intruction has executed is to execute SEV instruction on some other core.
In case of spin_lock( ),
- If IRQs are enabled even before we had called spin_lock( ) and we executed WFE and execution got suspended,
- Scenario 1: Interrupt occured and handled; we resume, but as the lock was still unreleased, we will loopback and execute WFE.
- Scenario 2: Some other core executed WFE and released some other lock (but didn't release our lock); we resume; as the lock is still unreleased, we will loopback and execute WFE.
- Scenario 3: Some other core executed WFE and released this lock; we resume; as the lock was released, we will acquire the lock.
- If IRQs are disabled before calling spin_lock(), then the situation is same as spin_lock_irqsave().
In case of spin_unlock( ),
- lock is released and SEV instruction is executed.
Check out the following code snippets for actual implementation:
static inline void arch_spin_lock(arch_spinlock_t *lock)
{
unsigned long tmp;
__asm__ __volatile__(
"1: ldrex %0, [%1]\n"
" teq %0, #0\n"
WFE("ne")
" strexeq %0, %2, [%1]\n"
" teqeq %0, #0\n"
" bne 1b"
: "=&r" (tmp)
: "r" (&lock->lock), "r" (1)
: "cc");
smp_mb();
}
static inline void arch_spin_unlock(arch_spinlock_t *lock)
{
smp_mb();
__asm__ __volatile__(
" str %1, [%0]\n"
:
: "r" (&lock->lock), "r" (0)
: "cc");
dsb_sev();
}
static inline void dsb_sev(void)
{
#if __LINUX_ARM_ARCH__ >= 7
__asm__ __volatile__ (
"dsb\n"
SEV
);
#else
__asm__ __volatile__ (
"mcr p15, 0, %0, c7, c10, 4\n"
SEV
: : "r" (0)
);
#endif
}
For more information, check arch/arm/include/asm/spinlock.h in Linux kernel source code. The above code snippet is from 3.4 kernel.
Spinlock implementation in ARM architecture的更多相关文章
- ARM architecture
http://en.wikipedia.org/wiki/ARM_architecture ARM architecture ARM architectures The ARM logo De ...
- ARM architectures
https://gitorious.org/freebsd/freebsd/raw/56c5165837bf08f50ca4a08c6b2da91f73852960:sys/arm/include/a ...
- [转]ARM/Thumb2PortingHowto
src: https://wiki.edubuntu.org/ARM/Thumb2PortingHowto#ARM_Assembler_Overview When you see some assem ...
- [转]ARM/Thumb/Thumb-2
ref:http://kmittal82.wordpress.com/2012/02/17/armthumbthumb-2/ A few months ago I gave a presentatio ...
- [转]iOS Assembly Tutorial: Understanding ARM
iOS Assembly Tutorial: Understanding ARM Do you speak assembly? When you write Objective-C code, it ...
- An Exploration of ARM TrustZone Technology
墙外通道:https://genode.org/documentation/articles/trustzone ARM TrustZone technology has been around fo ...
- ARM Holdings
http://en.wikipedia.org/wiki/Advanced_RISC_Machines ARM Holdings (Redirected from Advanced RISC Mac ...
- ARM WFI和WFE指令【转】
本文转载至:http://www.wowotech.net/armv8a_arch/wfe_wfi.html 1. 前言 蜗蜗很早以前就知道有WFI和WFE这两个指令存在,但一直似懂非懂.最近准备研究 ...
- 附录:ARM 手册 词汇表
来自:<DDI0406C_C_arm_architecture_reference_manual.pdf>p2723 能够查询到:“RAZ RAO WI 等的意思” RAZ:Read-As ...
随机推荐
- Android仿Win8界面的button点击
今天没事的时候,感觉Win8的扁平化的button还是挺好看的,就研究了下怎样在安卓界面实现Win8的扁平化button点击效果. 发现了一个自己定义的View能够实现扁平化button效果,话不多说 ...
- Git管理软件
软件下载地址 首先下载库 https://code.google.com/p/msysgit/ 接着安装 https://code.google.com/p/tortoisegit/ 然后就能够用了
- 制作 wordpress 博客静态化到本地
wget 克隆 wordpress 博客镜像 wget -e robots=off -w 1 -xq -np -nH -pk -m -t 1 -P "./wordpress.org" ...
- 初步使用RecyclerView实现瀑布流
先看效果 关于RecyclerView,真的是很强大. 个人觉得主要方便的地方是 1.直接可以设置条目布局,通过setLayoutManager LinearLayoutManager:线性布局,横向 ...
- 1.20 Python基础知识 - python常用模块-1
一.time和datetime 1.time模块 1)time.process_time() >>> import time >>> time.process_ti ...
- Linux桌面新彩虹-Fedora 14 炫酷应用新体验
Linux桌面新彩虹 --Fedora 14 炫酷应用新体验 650) this.width=650;" hspace="12" align="left&quo ...
- java 位操作 bitwise(按位) operation bit
java 位操作 bitwise(按位) operation bit //一篇对于 原码 反码 补码 的介绍 http://www.cnblogs.com/zhangziqiu/archive/201 ...
- Angularjs:实现全选
html: <div class="input-group"> <span class="input-group-addon" style=& ...
- Spring MVC框架实例
Spring MVC 背景介绍 Spring 框架提供了构建 Web 应用程序的全功能 MVC 模块.使用 Spring 可插入的 MVC 架构,能够选择是使用内置的 Spring Web 框架还是 ...
- 课程与教学管理系统(CMS):Sakai
课程与教学管理系统(CMS):Sakai 一.总结 java的spring.Hibernate等框架开发的 J2EE的开源cms 二.SAKAI Sakai是一个自由.开源的在线协作和学习环境,由Sa ...