文章翻译:albcamus
信息来源:邪恶八进制信息安全团队(
www.eviloctal.com)
Author: albcamus
Email:
albcamus@whitecell.org
Homepage:
http://www.whitecell.org
Date: 2005-11-30
Unreliable Guide To Locking
Rusty Russell
翻译:
albcamus
Copyright ?? 2003 Rusty Russell
This documentation is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
Suite 330, Boston, MA 02111-1307 USA For more details see the file COPYING in the
source distribution of Linux.
目录
1. 介绍
2. 并发带来的问题
2.1. 竞态条件与临界区
3. Linux内核中的锁
3.1. 两种主要类型的锁:自旋锁与信号量
3.2. 锁和单处理器内核
3.3. 只在用户上下文加锁
3.4. 在用户上下文与Softirqs之间加锁
3.5. 在用户上下文与Tasklets之间加锁
3.6. 在用户上下文与Timers之间加锁
3.7. 在Tasklets/Timers之间加锁
3.7.1. 同一个Tasklet/Timer
3.7.2. 不同的Tasklet/Timer
3.8. 在Softirqs之间加锁
3.8.1. 同一个Softirq
3.8.2. 不同的Softirqs
4. 硬中断上下文
4.1. 在硬中断服务例程与Softirqs/Tasklets之间加锁
4.2. 在两个硬中断服务例程之间加锁
5. 关于锁的使用的图表(Cheat Sheet For Locking)
5.1. 关于最低要求的表
6. 常见的例子
6.1. 都在用户上下文
6.2. 从中断上下文中访问
6.3. 把对象暴露在文件之外
6.3.1. 为引用计数使用原子操作
6.4. 保护对象自身
7. 常见问题
7.1. 死锁:简单与高级
7.2. 避免死锁
7.2.1. 对死锁的“防备过当”
7.3. Timer竞态:在内核中做一次游戏
7.4. 混乱的SPARC处理器
8. 加锁的速度
8.1. 读写锁变体
8.2. 避免锁的使用:读-复制-更新(Read Copy Update,RCU)
8.3. Per-CPU数据
8.4. 中断服务例程可能会使用哪些数据
9. 中断里调用哪些函数是安全的?
9.1. 一些可能睡眠的函数
9.2. 一些不会睡眠的函数
10. 进一步阅读
11. 致谢
术语(并翻译后记)
图表:
2-1. 预期结果
2-2. 可能结果
5-1. 加锁要求表
7-1. 顺序
WSS(Whitecell Security Systems),一个非营利性民间技术组织,致力于各种系统安全技术的研究。坚持传统的hacker精神,追求技术的精纯。
WSS 主页:
http://www.whitecell.org/
WSS 论坛:
http://www.whitecell.org/forums/