2008年8月16日 星期六

kernel source module

compile module:
1. cd  /usr/src/linux-x.y.z/
2. make modules

install module
1.  make modules_install

the generated module( ko)  is stored in /lib/modules/x.y.z/kernel/ 

2008年8月15日 星期五

patch

A patch is a text file containing source code differences between a development tree and the original snapshot from which the developer started work

apply patch:
ex:  if x.y.z-mm2.bz2 is a patch, go to the directory of linux source
      bzip2  -dc  ../x.y.z-mm2.bz2 |  patch -p1

create patch:
ex:
diff  -Nur   /path/originalKernal/    /path/newKernel  >  change changes.patch

global code browser

install:
http://www.gnu.org/software/global/global.html

run:
1. go to directory of source code
2. gtags
3. htags  ./codeTrace/
the generated html is in ./codeTrace/

2008年8月13日 星期三

find command

find  .  -name  "test.txt"
find text.txt under current directory

linux module location

/lib/modules/2.6.18-92.el5/kernel/drivers

2008年8月12日 星期二

HZ & jiffies

HZ是用來定義每一秒有幾次timer interrupts(time tick)

jiffies:
the number of time ticks since kernel start

ex:
unsigned long timeout=jiffies+ 3*HZ;
//  the time after 3 second
time_after(jiffies, timeout)

convert from jiffies to seconds
divide by HZ

time related methods:
time_after:  parameter is time tick 
time_before: parameter is time tick
schedule_timeout: parameter is time tick  
only schedule_timeout will give up processor

wait_event_timeout:
msleep: parameter is milliseconds

timer example( do something in the future):
#include

struct timer_list my_timer;

init_timer(&my_timer);            /* Also see setup_timer() */
my_timer.expire = jiffies + n*HZ; /* n is the timeout in number
                                     of seconds */
my_timer.function = timer_func;   /* Function to execute
                                     after n seconds */
my_timer.data = func_parameter;   /* Parameter to be passed
                                     to timer_func */
add_timer(&my_timer);             /* Start the timer */

2008年8月10日 星期日

smp

smp(多cpu)