01 2010 档案

摘要:在Emacs下用C/C++编程 版权说明和参考文献 按照惯例,我写的文章在最开始处放版权说明和参考文献。 参考文献: hhuu @ newsmth 的《Emacs的日常生活》 emacs 的文档 emacs 相关插件的文档 版权说明: 转载请注明转自曹乐的个人主页 www.caole.net,请保证全文转载,尤其不可省略这一部分。 序 用emacs写程序也有5个年头了,深切地体会到Emacs的... 阅读全文
posted @ 2010-01-28 17:39 napoleon_liu 阅读(2863) 评论(0) 推荐(0)
摘要:小写字母开头的 常量 是 erlang 中的原子,它相当于ruby 中的符号。 阅读全文
posted @ 2010-01-28 17:28 napoleon_liu 阅读(180) 评论(0) 推荐(0)
摘要:This article doesn't pretend to represent detailed description of customization of Emacs as development environment (this is theme for separate article). I just tried to provide a small description ... 阅读全文
posted @ 2010-01-28 17:27 napoleon_liu 阅读(1285) 评论(0) 推荐(0)
摘要:1. Emacs 自带的hippie-expand (参考的是王垠的) hippie-expand是 Emacs 自带的功能, 把M-/ 绑定到 hippie-expand,在.emacs文件中加入 ;;绑定按键 (global-set-key [(meta ?/)] 'hippie-expand) hippie-expand 的补全方式。它是一个优先列表, hippie-expand 会优先... 阅读全文
posted @ 2010-01-28 17:01 napoleon_liu 阅读(829) 评论(0) 推荐(0)
摘要:配置 回退键.emacs 文件中加入(define-key global-map "\C-h" 'delete-backward-char)(define-key global-map "\C-x?" 'help)这样就可以使用 C-h 来删除字符了。(帮助改为了 C-x ?)换行用 C-j (这会产生自动对齐) 回车使用 C-m撤消使用 C-/重做使用 C-x z (或 C-x ESC ESC... 阅读全文
posted @ 2010-01-28 10:57 napoleon_liu 阅读(274) 评论(0) 推荐(0)
摘要:注释 M-;(alt 键加 分号键) 要在下一行添加注释用 M-jM- - 表示 反的意思C-u 表示 参数 默认是4格式化 C-M-\全选 C-x h换行 C-j合并行 M-^跳到第N行 M-G M-G撤 销(undo) C-/ 或 C-x u 或 C - M - _重做(redo) C-x z自动补全 M-/ 或 C-M-/ (会显示列表)cscope 查找符号 C-c s s查找定义... 阅读全文
posted @ 2010-01-28 10:54 napoleon_liu 阅读(575) 评论(0) 推荐(0)
摘要:位操作 status |=  flags  /*设置标记*/ status &= ~flags /*清除标记*/ status & flags    /*判断标记*/   循环: do {} while(0) 方便从代码中退出( break; 不需要使用 goto) for(;;)  死循环; &... 阅读全文
posted @ 2010-01-14 15:16 napoleon_liu 阅读(350) 评论(1) 推荐(0)
摘要:x86 有 tr 寄存器,用来索引tss结构,tr 索引的是 GDT中的表项,描述符的类型必须是TSS。 tr寄存器,发生陷入时CPU就是从通过这个指针指向的TSS中拿到SS和ESP的值。   在linux中,每一个CPU对应一个TSS(而不是每个进程对应一个TSS),在同一个CPU上运行的进程共用一个TSS,由于每个进程的内核栈都不同(SS相同,但是ESP 不同),在某个CPU上正在... 阅读全文
posted @ 2010-01-14 14:53 napoleon_liu 阅读(1403) 评论(0) 推荐(0)
摘要:x86 实模式下,使用中断向量表(地址为0-1k的部分,每个向量4个字节); x86 保护模式下,使用中断描述符表 IDT. CPU中有 idtr 寄存器,保存 idt 表的位置, lidt 指令用于加载 idt 表到 idtr中。 idt 表中的 表项 是 8个字节, 一部分用户是段选择符,一部分是段内偏移量,还有中断DPL, 以及门类型(中断,陷阱,系统调用).   在一个... 阅读全文
posted @ 2010-01-14 11:32 napoleon_liu 阅读(390) 评论(0) 推荐(0)
摘要:"硬中断是外部设备对CPU的中断","软中断通常是硬中断服务程序对内核的中断","信号则是由内核(或其他进程)对某个进程的中断". 阅读全文
posted @ 2010-01-11 09:42 napoleon_liu 阅读(422) 评论(0) 推荐(0)
摘要: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 阅读(681) 评论(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 阅读(3701) 评论(0) 推荐(1)
摘要:2005 年 7 月 01 日 本文详细地介绍了 Linux 2.6 内核中新的锁机制 RCU(Read-Copy Update) 的实现机制,使用要求与典型应用。 一、 引言 众所周知,为了保护共享数据,需要一些同步机制,如自旋锁(spinlock),读写锁(rwlock),它们使用起来非常简单,而且是一种很有效的同步机制,在UNIX系统和Linux系统中得到了广泛的使用。但是随着计算机硬... 阅读全文
posted @ 2010-01-07 17:22 napoleon_liu 阅读(5146) 评论(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 阅读(1980) 评论(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 阅读(585) 评论(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 阅读(288) 评论(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 阅读(204) 评论(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 阅读(2263) 评论(2) 推荐(0)
摘要:设置 goto-line .emacs 中 添加   (global-set-key   "\C-c\C-g"   'goto-line) yasnippet     这个插件提供强大的 自动完成功能。 阅读全文
posted @ 2010-01-06 10:37 napoleon_liu 阅读(192) 评论(0) 推荐(0)