kernel virtual address to size caculation chat log 

I had an interesting chat with my friend qunying about how to caculate the hex presentation of address to a size:

(14:29:56) vincentinsz: on x86 32bit the kernel image located at physical address 1MiB, which translate to 0x00100000, but how 0x00100000 equals 1M, how to caculate it?
(14:32:00) qunying: 1024*1024 = 0x100000
(14:32:11) qunying: that is 1MiB
(14:33:56) vincentinsz: is there easy way to see 0x100000 as 1024 * 1024?
(14:34:18) qunying: just count the zeros
(14:34:36) qunying: one 0 in hex is 2^^2
(14:34:49) qunying: there is 5 zero, that is 2^^10
(14:35:00) qunying: that is 1M
(14:35:54) qunying: one 0 is 2^^4
(14:35:58) qunying: not 2,
(14:36:09) qunying: 5 zero is 2^^20
(14:37:59) vincentinsz: how do you get one 0 is 2^^4?
(14:38:27) qunying: for one number in hex represents 4 bits in binary
(14:38:55) qunying: 0x10 = 2^4, 0x100 = 2^8, etc
(14:40:01) vincentinsz: 0x10 = 1000 0000
(14:40:13) qunying: ya
(14:40:23) qunying: no
(14:40:29) qunying: 001 000
(14:40:34) qunying: 0001 0000
(14:40:47) vincentinsz: i see
(14:42:20) vincentinsz: what about some other hex address like 0xC0000000 which is about 3G, How to caculate
(14:45:10) vincentinsz: so there is 7 0s which is 2^^28?
(14:45:24) qunying: ya
(14:45:35) qunying: C is 1100
(14:46:00) qunying: so times 2^12
(14:46:35) vincentinsz: ah, so 2^^30 * 3?
(14:48:33) qunying: ya


---

[ add comment ] permalink ( 2.9 / 29 )
Learning Linux Kernel series 1 - Buffer Head 

First I read:

A nasty file corruption bug - fixed
http://lwn.net/Articles/215868/

The header for buffer head is include/linux/buffer_head.h


defines maxmum disk sectores/blocks as 8 per page, PAGE_CACHE_SIZE normally is the same size of PAGE_SIZE as 4k

#define MAX_BUF_PER_PAGE (PAGE_CACHE_SIZE / 512)

The function definition for buffer head is fs/buffer.c
[ add comment ] permalink ( 3 / 25 )
Asterisk app_mp3 patch to play m3u playlist file 

Asterisk app_mp3.c could only play one local single mp3 file, I patched it to play m3u playlist file randomly.

http://bl0g.blogdns.com/asterisk/app_mp3.patch
[ add comment ] permalink ( 3 / 30 )
Linux file system ext4 debate 

[ add comment ] permalink ( 2.9 / 31 )
Use vim and cscope to read large C source code project 

Vim is my favourite editor, I often use vim to read open source C code, Later, I found cscope is quite good tool to jump back and forth between different C source files to better understand how those C sources connect together in a large open source C code project.

cscopes_maps.vim can be downloaded from http://cscope.sourceforge.net/cscope_maps.vim, put this file under ~/.vim/plugin and run cscope -b -R -k under the folder of open source project, for example cd /usr/src/linux-2.28.x;cscope -b -R -k. then open a C source file, move cursor under a function name, press ctrl + ] will jump to the function declaration/definition of .c/.h file. use ctrl + t, ctrl + ^, etc to jump back and forth.

type :help cscope to get more help info about cscope at vim command mode, also vim folding can be helpful to get a broad picture of C source file, type :help folding to get more info about vim folding.
[ add comment ] permalink ( 2.7 / 6 )

Next