kernel内锁 完全解析.pdfVIP

  • 9
  • 0
  • 约3.43万字
  • 约 24页
  • 2018-06-01 发布于江苏
  • 举报
kernel内锁 完全解析

Kernel Locking 中文版 Unreliable Guide To Locking Rusty Russell rusty@.au 翻译: albcamus albcamus@163.com Copyright © 200 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 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 0 111-1307 USA For more details see the file COPYING in the source distribution of Linux. 第 1章. 介绍 欢迎进入 Rusty 优秀的《Unreliable Guide to Kernel Locking》细节。本文档描述 了Linux 2.6 内核的锁系统。 随着Linux 内核引入了超线程与 抢占 ,每一个 Hacking 内核的人都应该了解并发性 与为 SMP 加锁的基础知识。 第 2 章. 并发带来的问题 (如果你已知道并发是什么,请略过本章). 在一个普通的程序里,你可以这样为一个计数器增加计数: very_important_count++; 下面是你期望的结果: Table 2-1. 期望的结果 实例 1 实例 2 读 very_important_count (5) 加 1 (6) 写回 very_important_count (6) 读 very_important_count (6) 加 1 (7) 写回 very_important_count (7) 事情还可能这样发生: Table 2-2. 可能的结果 实例 1 实例 2 读 very_important_count (5) 读 very_important_count (5) 加 1 (6) 加 1 (6) 写回 very_important_count (6) 写回 very_important_count (6) 2.1. 竞态条件与临界区 这种情况,结果依赖于多个任务的相对执行顺序,叫做竞态条件。包含并发问题的代 码,叫做临界区。

文档评论(0)

1亿VIP精品文档

相关文档