Saturday, February 23, 2013

C-Tips

1. while reading from stdin using scanf(), newline is not read however it is ready to be read from very next scanf() call. to avoid this use %*c when reading. %*c will  read newline from buffer and discard it.

int nLine;
scanf("%d%*c", &nLine);  //after reading character in c, newline is read and discarded. and therefore next scanf will read from stdin


Friday, February 15, 2013

Questions came in my mind

1. In suspend, we flush all workques, all timers why?
2. A kernel thread is having an spinlock. At any time, processor is executing instruction protected by spinlock ( a device driver code), and at that instance, suspend sequence in initiated by user mode ( Android;  echo mem > /sys/power/state). Will device go to suspend?
3. A kernel thread is having an spinlock. At any time, processor is executing instruction protected by spinlock ( a device driver code), and at that instance, external interrupt is triggred, will interrupt gets higher priority and will it interupt handler is scheduled?

Thursday, February 14, 2013

VIM and code browsing

=> Install Tlist plugin
1. download taglist from http://www.vim.org/scripts/download_script.php?src_id=7701
# cd /usr/src
# wget -O taglist.zip http://www.vim.org/scripts/download_script.php?src_id=7701
OR Download it mannualy

2. Install the TagList Vim Plugin
# cd ~/.vim
# unzip /usr/src/taglist.zip

3. Enable the plugin in the ~/.vimrc, add folowing line
# vim ~/.vimrc
 filetype plugin on

=> How to use
:Tlist ;  lists all macro , functions, variables  on  left side  ( ctrl + w + w)
:ta <function name>
:vsp <file path>;  splits windows vertically (To switch between windows  (ctrl + w + w)) )