摘要: 今天用Python提取了Linux内核源代码的目录树结构,没有怎么写过脚本程序,我居然折腾了2个小时,先是如何枚举出给定目录下的所有文件和文件夹,os.walk可以实现列举,但是os.walk是只给出目录名和文件名,而没有绝对路径。使用os.path.listdir可以达到这个目的,然后是创建目录,由于当目录存在是会提示创建失败的错误,所以我先想删除所有目录,然后再创建,但是发现还是有问题,最好还是使用判断如果不存在才创建目录,存在时就不创建,贴下代码: 1 # @This script can be used to iterate the given directory,and create 阅读全文
posted @ 2011-07-25 23:03 justinzhang 阅读(1331) 评论(1) 推荐(0)
摘要: 到http://git-scm.com/ 下载git安装程序。 直接双击进行安装。 安装完成后启动Git Bash 进入命令行界面: 执行git clone命令拷贝linux源代码,git版本库地址是: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git http://git.kernel.org/pub/sc... 阅读全文
posted @ 2011-07-18 20:59 justinzhang 阅读(6862) 评论(1) 推荐(0)
摘要: A master boot record (MBR) is a type of boot sector popularized by the IBM Personal Computer.[1] It consists of a sequence of 512 bytes located at the first sector of a data storage device such as a h... 阅读全文
posted @ 2011-07-18 20:52 justinzhang 阅读(381) 评论(0) 推荐(0)
摘要: 在一个c文件中定义一个变量,在另外的c文件中引用该文件中的变量,变量默认是extern的,也就是对外部可见的,如果使用了static声明,那么这个变量就是对这个文件可见,其他模块是不可见的: 如下例: 阅读全文
posted @ 2011-07-18 20:41 justinzhang 阅读(543) 评论(0) 推荐(0)
摘要: 对二维指针进行sizeof运算是什么意思呢?(c08:Quoter.cpp)屏幕剪辑的捕获时间: 2011-07-17 10:19得到的结果如下所示:Sizeof quotes = 36,正好是指针的大小×一维指针的个数,sizeof *quotes是计算一维指针的大小,所以对二维指针进行sizeof 运算,得到的结果是二维指针中包含的一维指针的个数×一位指针的长度。 阅读全文
posted @ 2011-07-18 20:38 justinzhang 阅读(511) 评论(0) 推荐(0)
摘要: 一、定义 1.原码 正数的符号位为0,负数的符号位为1,其它位按照一般的方法来表示数的绝对值。用这样的表示方法得到的就是数的原码。 【例2.13】当机器字长为8位二进制数时: X=+1011011 [X]原码=01011011 Y=+1011011 [Y]原码=11011011 [+1]原码=00000001 [-1]原码=10000001 [+127]原码=01111111 [-127]原码=1... 阅读全文
posted @ 2011-07-18 20:36 justinzhang 阅读(6006) 评论(0) 推荐(1)
摘要: 有如下代码: 1: #include <stdio.h> 2: 3: #include <string.h> 4: 5: #include <malloc.h> 6: 7: #include <stdlib.h> 8: 9: typedef struct AA 10: 11: { 12: 13: int b1:5; 14: 15: int b2:2; 16: 17: }AA; 18: 19: in... 阅读全文
posted @ 2011-07-18 20:30 justinzhang 阅读(417) 评论(0) 推荐(0)
摘要: 1. /kernel/irq.c softirq_init 2.6.32.25 1.1 for_each_possible_cpu for ( ( ( cpu ) ) = - 1 ; ( ( cpu ) ) = cpumask_next ( ( ( cpu ) ) , ( cpu_possible_mask ) ) , ( ( cpu ) ) < nr_cpu_ids ; ) 1.2 per_cp... 阅读全文
posted @ 2011-07-18 20:16 justinzhang 阅读(935) 评论(0) 推荐(0)
摘要: 调用spin_lock_irqsave(&chip->lock,flags); 的下层实现是什么?#define spin_lock_irqsave(lock, flags) \do { \typecheck(unsigned long, flags); \flags = _spin_lock_irqsave(lock); \} while (0) 1: /* 2: 3: * Check at c... 阅读全文
posted @ 2011-07-18 20:10 justinzhang 阅读(3271) 评论(0) 推荐(0)
摘要: /* * 2011年4月8日22:49:50 * 作者:张超 * email:uestczhangchao@gmail.com * Linux2.6.32.25中如何获得当前进程的指针? */ //Thread_info.h //申明per_cpu_kernel_stack变量,它在其它位置定义,见下文内容. 1: DECLARE_PER_CPU(unsigned long, kernel_st... 阅读全文
posted @ 2011-07-18 20:03 justinzhang 阅读(2086) 评论(0) 推荐(0)