摘要: semaphore 和 completion 都要使用 wait_queue_t 来实现休眠。 但completeion 和 semaphore  本质都是整数 P, V操作和对0的判断; 而用户定义的 wait_queue_t 可以实现自己的操作和 休眠判断。 semaphore 和 completion 都是是同步机制(防止并发访问的冲突)。 wait_queue 是进程休眠... 阅读全文
posted @ 2010-01-08 10:58 napoleon_liu 阅读(668) 评论(0) 推荐(0) 编辑
摘要: 相关数据结构 首先看看信号量的相关数据结构: <include/linux/semaphore.h> struct semaphore { spinlock_t lock; #lock应该是这个信号量的自旋锁 unsigned int count; #count表示的是这个信号量的计数器 struct list_head wait_list; #wait_list顾名思义应该是等待链表... 阅读全文
posted @ 2010-01-07 17:22 napoleon_liu 阅读(3689) 评论(0) 推荐(1) 编辑
摘要: 2005 年 7 月 01 日 本文详细地介绍了 Linux 2.6 内核中新的锁机制 RCU(Read-Copy Update) 的实现机制,使用要求与典型应用。 一、 引言 众所周知,为了保护共享数据,需要一些同步机制,如自旋锁(spinlock),读写锁(rwlock),它们使用起来非常简单,而且是一种很有效的同步机制,在UNIX系统和Linux系统中得到了广泛的使用。但是随着计算机硬... 阅读全文
posted @ 2010-01-07 17:22 napoleon_liu 阅读(5065) 评论(2) 推荐(2) 编辑
摘要: 从2.6.10开始,Linux内核提供了一个通用的环形缓存(我喜欢称为环形队列);它的头文件是<linux/kfifo.h>,kfifo.c是实现代码。 在设备驱动中环形缓存出现相当多. 网络适配器, 特别地, 常常使用环形缓存来与处理器交换数据(报文)[LDD3]。 见下面的图“LDD3中描述的队列”。 我们来看下kfifo的数据结构: struct kfifo { unsign... 阅读全文
posted @ 2010-01-07 14:37 napoleon_liu 阅读(1945) 评论(0) 推荐(0) 编辑
摘要: 锁无关的(Lock-Free)数据结构 在避免死锁的同时确保线程继续 http://blog.csdn.net/pongba/archive/2006/01/26/588638.aspx Andrei Alexandrescu 刘未鹏 译 Andrei Alexandrescu是华盛顿大学计算机科学系的在读研究生,也是《Modern C++ Design》一书的作者。他的邮箱是 andr... 阅读全文
posted @ 2010-01-07 14:27 napoleon_liu 阅读(573) 评论(0) 推荐(0) 编辑
摘要: lock-base 机制   semaphore(P 减操作,  V是加操作) semaphore 在SMP中都要用到 memory  barrier , 通过唯一的内存访问来保证一致性。   mutex( 资源为 1 的semaphore) read/write lock (semaphore的衍生, reade pv: 1, write pv... 阅读全文
posted @ 2010-01-07 11:43 napoleon_liu 阅读(272) 评论(0) 推荐(0) 编辑
摘要: Manifesto for Agile Software Development We are uncovering better ways of developing software by doing it and helping others do it. Through this work we have come to value: Individuals and interactio... 阅读全文
posted @ 2010-01-07 11:17 napoleon_liu 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Linux内核Makefile文件 --译自Linux2.6.x Kernel Makefiles http://bbs.zndev.com/htm_data/12/0510/100065.html 本文档描述了linux内核的makefile文件。 === 目录      === 1 概述      === 2 角色... 阅读全文
posted @ 2010-01-06 10:40 napoleon_liu 阅读(2233) 评论(2) 推荐(0) 编辑
摘要: 设置 goto-line .emacs 中 添加   (global-set-key   "\C-c\C-g"   'goto-line) yasnippet     这个插件提供强大的 自动完成功能。 阅读全文
posted @ 2010-01-06 10:37 napoleon_liu 阅读(184) 评论(0) 推荐(0) 编辑
摘要: gem    gem 是ruby 的包管理系统,类似于ubuntu 的 apt-get. 命令 安装包:gem install your-package 移除包:  gem uninstall your-package 查询:     gem query –ln your-wanted (本地)   ... 阅读全文
posted @ 2009-12-30 17:33 napoleon_liu 阅读(1060) 评论(0) 推荐(0) 编辑