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
Linux-Android
This is the place, I will share my experience on linux and Android as and when I learn new things. I will welcome and appreciate any comment/suggestions on the posts which will help me as well as any new comer.
Saturday, February 23, 2013
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?
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)) )
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)) )
Sunday, September 23, 2012
Basic git commands
//Adding to git repository
$ git init
$ git add .
$ git commit
//To see logs
$ git log
git log HEAD/HEAD~1/HEAD~2
//creating patch
git add <filepath/file name>
git commit
git format-patch HEAD~1
//applying patch
git apply --stat fix_empty_poster.patch
git apply --check fix_empty_poster.patch
git am --signoff < fix_empty_poster.patch
//Undo changes
git reset --hard HEAD ; reset to HEAD
git reset HEAD ; it will keep unstaged changes
Steps to submit a patch in git :
clone the branch
git clone <branch addess> -b <local repo name>
1. git reset --hard <commit id>
2. git remote update
3. git pull
4. Add the modified files to repository you created
$ git add file1 file2 file3
5. We can see what is about to be committed using git diff with the --cached option.
$ git diff --cached
$ git status
6. Before commiting our Changes in GIT, run the script if any. e.g. testScript.pl script
$ git diff --cached| <path>/testScript.pl --no-signoff -
7. commit your changes.
$ git commit -s
8. Push Your changes
$ git push
$ git init
$ git add .
$ git commit
//To see logs
$ git log
git log HEAD/HEAD~1/HEAD~2
//creating patch
git add <filepath/file name>
git commit
git format-patch HEAD~1
//applying patch
git apply --stat fix_empty_poster.patch
git apply --check fix_empty_poster.patch
git am --signoff < fix_empty_poster.patch
//Undo changes
git reset --hard HEAD ; reset to HEAD
git reset HEAD ; it will keep unstaged changes
Steps to submit a patch in git :
clone the branch
git clone <branch addess> -b <local repo name>
1. git reset --hard <commit id>
2. git remote update
3. git pull
4. Add the modified files to repository you created
$ git add file1 file2 file3
5. We can see what is about to be committed using git diff with the --cached option.
$ git diff --cached
$ git status
6. Before commiting our Changes in GIT, run the script if any. e.g. testScript.pl script
$ git diff --cached| <path>/testScript.pl --no-signoff -
7. commit your changes.
$ git commit -s
8. Push Your changes
$ git push
setting cpu frequency, and governors
Following files can be used to manipulate cpu frequency
"/sys/devices/system/cpu/cpu0/cpufreq/" .
>cd sys/devices/system/cpu/cpu0/cpufreq/
To set the cpu at maximum frequency ,
>echo performance > scaling_governor
verify it by
>cat cpuinfo_cur_freq
it should be 1GHz.
To choose the max and min limit of scaling frequency.
>echo conservative > scaling_governor
>echo maxfreq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
>echo minfreq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
After this cpu will scale the cpu frequency between maxfreq and minfreq.
To force the cpu to run at particular frequency
> echo conservative > scaling_governor
> echo 800000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
> echo 800000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
verify it by
> cat cpuinfo_cur_freq
it should be 800000.
To set the cpu at lowest frequency .
>echo powersave > scaling_governor
verify it by
>cat cpuinfo_cur_freq
it should be 100000.
"/sys/devices/system/cpu/cpu0/cpufreq/" .
>cd sys/devices/system/cpu/cpu0/cpufreq/
To set the cpu at maximum frequency ,
>echo performance > scaling_governor
verify it by
>cat cpuinfo_cur_freq
it should be 1GHz.
To choose the max and min limit of scaling frequency.
>echo conservative > scaling_governor
>echo maxfreq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
>echo minfreq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
After this cpu will scale the cpu frequency between maxfreq and minfreq.
To force the cpu to run at particular frequency
> echo conservative > scaling_governor
> echo 800000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
> echo 800000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
verify it by
> cat cpuinfo_cur_freq
it should be 800000.
To set the cpu at lowest frequency .
>echo powersave > scaling_governor
verify it by
>cat cpuinfo_cur_freq
it should be 100000.
Subscribe to:
Posts (Atom)