My Writings. My Thoughts.
Introducing Lipsy, Bigo and Dot
June 20th, 2010 | 2 Comments »
A very hectic weekend, but one cute thing happened. I visited a pet shop which used be my favorite when I was a kid. As soon as I entered the shop, the lady that works recognized me and was reminding me how I used to spend one full day watching all the fishes in the shop and explaining others about different breeds … heh, that’s so true and it was very nostalgic. My family and I finally got over our Arowana that passed away after being loyal pet for almost 10 years. So I thought I’ll shop for new members to my aquarium.
I came across these fishes with cute mouth and I loved them…called “Parrot Cichlids”.. Interesting thing is one of the fishes had red colored lips …. lol .. it was so cute and funny … I bought three of them, I know it’s an odd number .. but the thing is the pet shop folks themselves didn’t have a matching pair for any of these three…but they promised me they will get for me… let’s see.. So here they are, the first one – Lipsy, for her cute lips…apart from her lips, another interesting thing is the flowers in her body… two red flowers with distinct petals and stem on both sides.. amazing…
Side view:
And then the big guy .. Cichlids are known to be very responsive to humans and they recognize their boss.. he is the biggest of all and I was playing around with him … he was following my hand movements with his funny chewy mouth..lol… looked very sharp, smart and very observing.. I picked him and named him Bigo.
Side view:
And finally this dude, who reminded everyone in my family of a stuffed toy fish…seriously, his shape is very clear and distinct, smooth and fanned out fins… sight was beautiful and got him .. named him Spot.
All three together -
My tank has lot of stains .. Grr.. I think I am saying that coz I made my mind to buy that gorgeous imported fish tank with no joints anywhere. that I saw in the pet shop.. heh, let’s see.
If likely, unlikely macro linux kernel
May 4th, 2010 | No Comments »
You will see the macros likely(), unlikely() used all over the kernel. What is the use of it? From gcc version 2.96, a programmer can specify the compiler to optimize the instructions by giving it some information about branch prediction. This is what (un)likely() macro does for you.
You can see the definition of this macro is /include/linux/compiler.h defined as :
62 #define likely(x) __builtin_expect(!!(x), 1) 63 #define unlikely(x) __builtin_expect(!!(x), 0) <pre>
Let’s consider a trivial example:
<pre>devil@evilemp:~/test$ cat test.c
void test(int d)
{
/* It is very unlikely that the if condition is true */
if( __builtin_expect(d,0))
{
d = 4;
}
d = 5;
}
devil@evilemp:~/test$ gcc -freorder-blocks -c test.c
devil@evilemp:~/test$ objdump --disassemble test.o
test.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <test>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 89 7d fc mov %edi,0xfffffffffffffffc(%rbp)
7: 8b 45 fc mov 0xfffffffffffffffc(%rbp),%eax
a: 48 98 cltq
c: 48 85 c0 test %rax,%rax
// Compiler branches the if part
f: 74 07 jne 18 <test+0x18>
// Keeps the instruction after if sequential d = 5
11: c7 45 fc 04 00 00 00 movl $0x5,0xfffffffffffffffc(%rbp)
// Finally the assignment d = 4;
18: c7 45 fc 05 00 00 00 movl $0x4,0xfffffffffffffffc(%rbp)
1f: c9 leaveq
20: c3 retq
<pre>
Ok, how about it's real practical uses? One example will be when you allocate memory.If you are allocating memory in the user space, it's very unlikely that you will run out of space. You can use the unlikely macro here.
Another beautiful example is the kernel code where we check for process priority. It's very unlikely that a process will have a real time priority. You can see this usage in the cpu scheduling code.
How to Turn Off Beep Sound in PC ?
May 4th, 2010 | No Comments »
If you are one among few developers who gets annoyed by the beep sound from pc speaker while playing with Linux, this is how you get rid of it :
open the following file using your favorite editor
/etc/modprobe.d/blacklist
add these lines:
#disable speaker sound
blacklist pcspkr
and after the next reboot you won’t hear the beep sound. If you don’t want to reboot the machine, after adding those two lines, you can remove the module that controls the pc speaker by running this command :
=>sudo rmmod pcspkr
Good Luck!







