2009年12月31日 星期四

Articles about cscope+vim+ctags+taglist

http://cscope.sourceforge.net/cscope_vim_tutorial.html
http://blog.verycd.com/yoyopub/showentry=22855
http://adrianhuang.blogspot.com/2007/09/trace-code-gvimctagscscope.html
http://blog.chhsu.org/2009/03/multi-projects-of-vim-using-cscope.html

  • Install Ctags
$sudo apt-get install exuberant-ctags
  • Install Cscope
$sudo apt-get install cscope
  • Make Sure Your Vim Support Cscope
$ vim --version | grep cscope
  • Download Cscope Plugin
$ mkdir ~/.vim/pluging
$cd ~/.vim/plugin
$ wget http://cscope.sourceforge.net/cscope_maps.vim
  • Install Taglist

Download tagliast from http://vim-taglist.sourceforge.net/download.html.
Follow the installation steps from http://vim-taglist.sourceforge.net/installation.html
Add the following line into your .vimrc will help you to open taglist and switch between tag and editor window.

filetype on
nnoremap < silent > < f2 > :TlistToggle < cr >
nnoremap < silent > < f3 > :wincmd p < cr >


  • Generate DB & test


#!/bin/bash
CSCOPE_FILE=cscope.out
if [ -n "$1" ]; then
echo "Source code directory: " $1
echo "Create file map : " $CSCOPE_FILE
find $1 -name "*.h" -o -name "*.c" -o -name "*.cpp" > $CSCOPE_FILE
cscope -bkq -i $CSCOPE_FILE
# cscope -Rbkq
ctags -R
else
echo "Please key-in path of project"
fi

$cd source-code
$
cscope
  • Other IDEs
Other IDE includes Anjuta or Source Navigator. You can try it.





2009年12月25日 星期五

Memory remap



  • ioremap
The function will map a range of I/O space to kernel space. That fix page table of some kernel memory to physical I/O memory. You can access the mapped kernel space as if you are accessing physical I/O memory.
  • io_remap_pfn_range, remap_page_range
Remap address range in the kernel space to user space. User space process can access the mapped kernel address range by accessing user-space address.


2009年12月22日 星期二

Run level

debian的runlevel級別定義如下:
0 - Halt
1 - Single
2 - Full multi-user with display manager (GUI)
3 - Full multi-user with display manager (GUI)
4 - Full multi-user with display manager (GUI)
5 - Full multi-user with display manager (GUI)
6 - Reboot

而redhat的runlevel級別定義如下:
0 - Halt
1 - Single
2 - Not used/User definable
3 - Full multi-user NO display manager
4 - Not used/User definable
5 - Full multi-user with display manager (GUI)
6 - Reboot

You can modify your default run-level:
1. Ubuntu: edit /etc/event.d/rc-default
2. Redhat: edit /etc/inittab

2009年12月12日 星期六

Kernel scheduling

  • Schedule
You can relinguish your control of CPU. Scheduler will run another task.

REF: schedule()
  • Wait queue
When you can't satisfy user request, put them in wait queue. It's like a I/O wait queue in OS text book.

REF: init_wait_queue_head(), interruptible_sleep_on(), wake_up()

Note: You can also put yourself in the wait queue (when waiting for I/O) by manually:

DECLARE_WAIT_QUEUE(wait, current);
add_wait_queue(wait_q_head, &wait);
while(!condition){
    set_current_state(TASK_INERRUPTIBLE);
    schedule();
}
set_current_state(TASK_RUNNING);
remove_wait_queue(q, &wait);
  • Kernel timer
You can trigger an kernel timer for a delay execution.

REF: init_timer(), del_timer(), add_timer()
  • Task queue
You can use task queue for a delay execution. Very similar to kernel timer. Kernel maintain three pre-defined task queue: scheduler queue, tq_timer, tq_immediate

REF: INIT_TQUEUE(),queue_task(), schedule_task(), DECLARE_TASK_QUEUE(), run_task_queue()

  • Tasklet
You can use a tasklet to schedule a interrupt work in bottom half. It is build on top of softirq

REF: DECLARE_TASKLET(), tasklet_init(), tasklet_schdule()