Random Walk of Life

A GTalk chat-bot

Posted in geek, interesting by ego on May 1st, 2008

Ever wondered why can’t we have a chat-bot that responds when we’re idling or away ?

Sathya tried this a couple of times while he “appeared” to be away on GTalk by responding something like “The recipient of your message is currently inactive”.

One could argue saying that the status should reflect what the person is doing. But then, more often than not, my friends’ status always say they’re Busy, but ping them, and you’ll end up spending an hour or two chatting nonsense!

Anyway, requirement or not, I think it’s a pretty cool thing to have a Bot that can respond on your behalf. Even better, how about integrating a “Mirror Bot” which echoes back whatever the buddy has just typed, or a “Emacs Psychiatrist Bot” which will piss the shyte out of your buddy?

Hmmm.. Probably against the social networking etiquettes.

Thoughts on that?

Cause and Effect

Posted in fundoo, geek, interesting, linux, programming by ego on April 4th, 2008

While working on idle power management, I used vaidy’s klog based patches to profile an idle system to obtain stats such as:

* The time when a cpu enters into the tickless idle mode
* The various interrupts that bring the cpu out of idle state.
* The timers that expire in this interval and cause a wake up.
* The tasks that demand/ or are made to be wake up on the idle cpu.
* The time when the cpu comes out of the tickless idle mode and starts executing the tasks.

While observing the task wakeup instrumentation data, I noticed that the wakeup statistics for kondemand appeared pretty strange. For the uninitiated, kondemand is a kernel thread that belongs to the ondemand governor of cpufreq subsystem, which changes the p-states of the system, based on the utilization statistics. Thus it’s something that helps in power management.

root@llm43 tests]# ps aux | grep kondemand | head -4
root 1143 0.0 0.0 0 0 ? S< 09:21 0:00 [kondemand/0]
root 1145 0.0 0.0 0 0 ? S< 09:21 0:00 [kondemand/1]
root 1146 0.0 0.0 0 0 ? S< 09:21 0:00 [kondemand/2]
root 1147 0.0 0.0 0 0 ? S< 09:21 0:00 [kondemand/3]

From the file wakeups.txt, an output of my profiling experiment,

pid cpu nr_wakeups
————————–
1143 0 468
1145 1 279
1146 2 78
1147 3 68

Couple of things bothered me here.

  1. The unusually high number of wakeups on CPU0 and CPU1. kondemand was wakeing up approximately at the rate of 4 time and 2 times respectively on these cpu’s over a observation idle period of 120 seconds.
  2. The difference in the number of wakeups by kondemand on the different CPUs.

Bewildered, I fired a mail to Venki asking for possible explanations.
And I started looking at the code. Now, the number of times the kondemand thread is supposed to check for a change in the frequency is determined by this sysfs tunable called sampling_rate. It was set to 256000us on my system. Which accounted for the unusually high number of wakeups on the CPUs.

But I was still confused. The sampling_rate is a global tunable which maps to the variable dbs_tuners_ins.sampling rate, which is common to all the kondemand threads. Then why the different wakeup rates on different CPUs?

Venki replied to my original query reminding me that kondemand uses deferrable timers! That explained everything.

Deferrable timers, behave normally on a busy system. But on a idle system, when are about to decide when should we wake up next inorder to service the next timer in the list, we skip any deferrable timer we encounter.Thus, a deferrable timer on an idle cpu would expire when the next nearest *hard* timer would expire.

So, the reason why CPU0 and CPU1 were having such high number of wake ups on an idle system can be accounted to the fact the expiry of some other timer like the ehci_watchdog would trigger the expiry of kondemand timer, and along with it the wakeup of the kondemand thread! And depending on the number of timers that are queued on different CPUs, we have the corresponding number of wakeups of kondemand thread!

So, what I was thinking to be the major cause for wakeups in the kernel, turned out to be an effect of the expiring timers queued by a totally unrelated subsystem, thus confirming the old wisdom of mathematical logic: “If two events occur one after the other, it doesn’t necessarily imply that one is the cause for the other”

Recently Discovered

Posted in interesting, music, programming by ego on March 28th, 2008
Tagged with: , ,

Lawyers and a light bulb

Posted in geek, humor, interesting by ego on March 27th, 2008

Q: How many Lawyers does it take to change a light bulb?

A: Whereas the party of the first part, also known as “Lawyer”, and the
party of the second part, also known as “Light Bulb”, do hereby and forthwith
agree to a transaction wherein the party of the second part shall be removed
from the current position as a result of failure to perform previously agreed
upon duties, i.e., the lighting, elucidation, and otherwise illumination of
the area ranging from the front (north) door, through the entryway, terminating
at an area just inside the primary living area, demarcated by the beginning of
the carpet, any spillover illumination being at the option of the party of the
second part and not required by the aforementioned agreement between the
parties.
The aforementioned removal transaction shall include, but not be
limited to, the following. The party of the first part shall, with or without
elevation at his option, by means of a chair, stepstool, ladder or any other
means of elevation, grasp the party of the second part and rotate the party
of the second part in a counter-clockwise direction, this point being tendered
non-negotiable. Upon reaching a point where the party of the second part
becomes fully detached from the receptacle, the party of the first part shall
have the option of disposing of the party of the second part in a manner
consistent with all relevant and applicable local, state and federal statutes.
Once separation and disposal have been achieved, the party of the first part
shall have the option of beginning installation. Aforesaid installation shall
occur in a manner consistent with the reverse of the procedures described in
step one of this self-same document, being careful to note that the rotation
should occur in a clockwise direction, this point also being non-negotiable.
The above described steps may be performed, at the option of the party of the
first part, by any or all agents authorized by him, the objective being to
produce the most possible revenue for the Partnership.

:D

Discovered it as one of the fortune riddles

Tagged with: ,

Ambigrams

Posted in art, experiences, interesting by ego on March 16th, 2008

Opening Mood: Lunch time!
Opening Song: None

For the past couple of days, I have been crazy about Ambigram. So much that I haven’t checked my mails nor have thought about some of the outstanding todo items in my list.

It all started with Pradeep telling me about tattoos and what would be a good design for one. It struck me then, that an Ambigram would make an excellent choice for a tattoo owing to it’s symmetric nature. I had first read about Ambigrams in Dan Brown’s “Angels and Demons” and at that time, I thought, well, may be one needs to be an artist to draw one of these.

But no! When Pradeep said that it would be difficult to ambigrammize some of our names, I somehow wanted to prove him wrong! And the result, two night outs worth of time spent doing nothing but trying to arrange shapes so that they appear symmetric along the horizontal axis. Of every name I could think of! The last time I forgot about everything and spent night outs doing crazy things such as these was way back in 3rd year engineering, trying to come up with Anagrams of words :)

Anyway, here are a few ambigrams that I made. There are more, but they need fine tuning, and as an how I get time to fine tune them, I will be uploading them here. Below each picture, you’ll find what they mean, just in case the symbols are too cryptic. Well, it’s also a way of fooling your mind. Once you know what the Symbol means, your mind will be compelled to see it that way ;)

All these ambigrams were made using GIMP, the GNU image manipulation program.

Copyrights?! Well, Open Source philosophy applies here too. I grant you complete rights to use them, improve upon them, and if you like the improvement/enhancement, share them with others :)

Gautham

GAUTHAM

——————————————————————————————————————————————–

Kevin

KEVIN
——————————————————————————————————————————————–
Mili

MILI
——————————————————————————————————————————————–

Sathya

SATHYA
——————————————————————————————————————————————–

Sapna

SAPNA
——————————————————————————————————————————————–

Rachita

RACHITA
——————————————————————————————————————————————–

And this one. This one is an Asymmetric Ambigram. In the sense that it has two names in the same figure. There’s another asymmetric ambigram that I have made, but it needs legal clearance before it can be posted :P

Chirag

CHIRAG

… And when you turn this around, it looks like this:

Leena

LEENA
——————————————————————————————————————————————–
Comments, feedback much appreciated. So do drop a message :)
Also, if you have seen some really nice Ambigrams elsewhere, do share them/pointers to them here.

Closing Song: None.
Closing Mood: Lazy Sunday Afternoon

A Bet of Death By Chocolate. Insert comma’s in the right places!

Posted in Views, events, food, humor, interesting by ego on February 12th, 2008

Opening Mood: This is insane!
Opening Song: None.

Like I mentioned in my previous post I was out for the whole of last week and am catching up with the happenings. One of the hilarious things that came to my notice is that one of my friends, lets say K, who usually boasts of his HUGE appetite has claimed that he/she can eat 4 Death By Chocolates in a single stretch.

I love chocolate. If something can keep me awake a whole night after a night out is a bar of dark chocolate. But I have my limits and last time I checked it was 1.5 large cups of Death by Chocolate (DBC), a popular ice-cream offering at this joint named Corner House. So naturally I was very much excited about this claim. So we had a bet:

  • If K can have 3 DBC’s at a single stretch, we shall sponsor the 4th one.
  • If K can finish the 4th one, we will reimburse all the four and any subsequent DBC that K might want to have (owing to his large appetite) and K wins a cool thousand bucks for his/her feat!

Subject to following conditions:

  • K should have a normal diet for the earlier part of the day, i.e no skipping breakfast or lunch.
  • K should be in a perfectly healthy state after consuming 4 DBCs for atleast 2 hours. No, puking is not allowed.
  • Should K give up in the middle, we’re entitled to two big treats on any days at Corner House of our choice from K.
  • Should K withdraw from the bet, we’re entitled to a big treat on any days at Corner House from K.

Just out of curiosity, I created this poll on what people think is their DBC limit. and what they think is any person’s maximum DBC limit.

You can find the poll here -> http://freeonlinesurveys.com/rendersurvey.asp?sid=lo073kc9y2xif4g394813

The Poll responses when I last checked were as follows :

q1_44

    A) None, I hate chocolates.
    B) One, but thats it.
    C) Two, I am feeling sleepy now.
    D) Three, I like chocolate.
    E) Four, Burp, i am full!
    F) More than Four, I am superhuman

    q2_44

    A) Yes
    B) No

    I will be updating these results as and how my time permits. So this is not real time :)

    Please do take the poll since there are only 2 questions and it hardly takes 15 seconds of your time.

    Hey, being a good friend, I think it’s my duty to let K to know what he/she is attempting after all :)

    Closing Song: None
    Closing Mood: Waiting for your responses.

    PS: K prefers to remain Anonymous. So even if you want to take a guess on his/her identity, please don’t mention him/her in the comments.

    A Geeky Vacation!

    Posted in academia, books, geek, interesting, linux by ego on February 12th, 2008

    Opening Mood: I’m back!
    Opening Song: Romantic Piano - Chopin

    Spent the last week at this place called Kudremukh. It used to be one of Karnataka’s famous mines before the operations were shut down in 2005. So now it is just a nice little place with lots of greenery and very few people to bother an occasional guest. Which was me :)

    I started from karkala on 4th Feb at 8:00 AM to Kudremukh. I had booked a room for myself at the Sahyadri Bhavan lodge for five days through some family contacts. Reached the place at around 9:30 A.M. The ride was very good, and one could spot a lot of trees and forests on the way. Once you cross the Mala outpost, the weather becomes quite pleasant owing to the trees around.

    The room where I was put up was really a big one. It had three beds, a balcony, and an attic! All for an extremely cheap then of Rs 200 per day! The guest house has a small restaurant which serves breakfast, lunch and dinner. Again, at very affordable rates. I liked the food there. But then, I also stayed for four years at NITK Surathkal and survived the mess food. So I really shouldn’t be talking about how good the food at any place is :P . The place also has a very nice town park where I used to go in the evenings for a stroll.

    The purpose of the vacation was to do stuff which I had always wanted to do, but never got the time. Starting problem you can say :) . Over the past couple of years, I have been accumulating quite a bit of technical stuff to read, and the list was only growing. So I wanted to take some time off and get started on some of those items.

    Thus I had five days at a place with very little disturbance and an awesome climate. Really, I couldn’t ask for more. The working style was simple. Start with one work item, when you get bored, move on to the next one. There were no other rules. No hard deadlines to finish this or that by the end of 5 days. Just have fun :)

    So, in the five days, I read through parts of Linux Memory management. Two years of programming the kernel, and I was still not aware of how Linux manages the memory across the various platforms it supports. So I had to go back to the very basics, starting from the 386 memory management model and then how Linux represents it using a 4 level model. After that, I read up on the Zoned Buddy Allocator, the Slab Allocator and a part of Process address space. I was using “Understanding the Linux Kernel, 3ed” and 2.6.24 kernel code as reference.

    Other than that, RB-trees was something I read about and implemented during this time. It reminded me a lot about AVL trees, which we had studied in our data-structures classes. RB-trees was actually easier to implement (atleast the deletion part).

    Also, read the first three chapters from Ulrich Drepper’s “What every programmer must know about memory”. The paper is true to it’s name. Especially the chapter on caches. The paper gives a very clear picture of the implications of having different levels of caches, how the cache size matters, through various well designed experiments. It should be read by anyone who is interested in doing any kind of system programming.

    Other than these, did a whole bunch of fun stuff, like wrote a ascii visualization tool for trees. One of the problems I had with the Data structures lab assignement was that we had to show the output through an inorder, or a breadth order traversal. And that was not always very easy to visualize. But then I was one of those who did the class assignments when there was only one or two days left for the deadline. So I guess I am doing all the supplemental things now :)

    Oh yeah, spent a whole evening reverse engineering this obfuscated C Code which prints the poem about the various gifts given by the true love on each day of Christmas. Am planning on writing a small article on that. How recursion was used in place of loops and how the ‘,’ operator was used for statements. It’s a code when you see, you’ll go “This hurts my brain!” . Check it out here.

    And when I had time to spare, I read some chapters from Jon Bentley’s “Programming Pearls”. Another book which I would recommend to anyone interested in serious programming. This book sure is fun!

    So, now that I am back, the first thing to do would be to catchup with a week of email. Oh well :)

    Closing Song: Marriage of Figaro - Mozart.
    Closing Mood: Anxious to catch up with last week’s happenings.

    Repressed and Rebels

    Posted in Views, experiences, fundoo, interesting, reflections by ego on September 4th, 2007

    Opening Mood: Good Morning, and I’m still grumpy
    Opening Song: None.

    I saw him at the coffee house yesterday. It’s been more than a year since we last met. He hasn’t changed a bit. Dressed in a loose T-shirt and a pair of faded jeans, he looked casual as ever. He saw me and the next moment, he was at my table. So typical of him, I thought!

    “Wassup dude! Howz life? How’s that Linux thing of yours goin on?” , he asked.

    I told him about my work, and the interesting stuff that was happening there. He listened to all of it with great interest.

    So, it’s not t O(1) anymore, eh?! Nice. Will check that out sometime.” He said.

    I asked him about his work, and life.

    “Going on! I am enjoying it. Nothing to do with what we studied back in college. But doing good.”

    I felt happy for him. Finally the chap had found something which has managed to hold his attention for this long. Good for him!

    “I’ll be quitting next week. There’s this other cool thing I read about the other day. Will be working on it!”

    I guess he loved the expression on my face, when he said that. Because he gave me that wicked smile.I asked him if he had any definite plan about this other thing.

    “Nope! It’s still in a very nascent stage. Will fiddle with it for a while.”

    I really couldn’t believe it!

    This is one of those people who has real potential to change the world. Instead of realizing it, here he was “Wandering! Yup, that I am. And I like it. I feel extremely light.”

    Fear of the C-word?, I asked him.

    “Not at all! It’s just the futility of commitment. I don’t see the point in it. Simply cannot understand how can I make a promise to accomplish something, when there may be thousands of interesting things on the way. I can’t just ‘let-go’ of these things. I will be interested in stopping and having a look around. And may be, one of these things’ll drive me on a different path, which may never meet the first one. And, I don’t wanna keep anyone waiting for me!”

    I gave a puzzled look that demanded further explanation.

    “Dude, I don’t want to be defined by some one thing that I do in life. I’ve seen it happen before. You show your interest in something, and people around you create an image, associating you with that thing. And in course of time, you yourself accept that image, and feed it further. One fine day, when you discover something else which is “fun”, the same people tell you that the “fun” thing doesn’t fit your image or it’s extrapolations. And thus, you automatically become a member of the society’s “Repressed or Rebels Club”. The moment you let something define you, you are enslaved by an obligation to do well in that. Sometimes it happens without your knowledge. And you start thinking - ‘But this is what I wanted to do all the while! So I should be happy.’ Just that my idea of happiness isn’t preceded by conditionals.”

    I started laughing. I understood what he was talking about. I got up. This meeting was over.

    He was still sitting there, smiling.

    I paid our bill, picked up my stuff, plugged in my iPod and bid him adieu. Led Zep’s voice filled my brain.

    Stairway to the heaven. Man, people sure *do* wanna buy that thing! I started walking back home.

    Yes there are two paths you can go by, but in the long run.
    There’s still time to change the road you’re on.

    Closing Song: None.
    Closing Mood: Wide awake.

    Cpu-Hotplug and KBC

    Posted in geek, humor, interesting, linux by ego on April 24th, 2007

    Opening Mood: Sleepy. Night out did me in.
    Opening Song: Flight of Fantasy - Yanni.

    Just couldn’t help laughing at the thought of this one (at the risk of being accused of thinking about nothing else other than … you’ll know what!)

    Some years ago, when cpu-hotplug was first introduced, the way to postpone a cpu-hotplug operation while operating in some critical section was by using the API lock_cpu_hotplug().

    Some years ago, when Kaun Banega Crorepati (KBC) was first launched with Mr. Amitabh Bacchan as the host, the famous catchline was “lock kiya jaaye” ( Let’s lock it)

    A few months ago, after being fed up with the ruckus created by the global cpu-hotplug lock, Andrew Morton suggested that we kill lock_cpu_hotplug() and use freeze_processes() instead. That’s what I have been working on for the past few months.

    A few months ago, when KBC version 3 was launched with Shah Rukh Khan as the host, the catchline became - “Mr Computer, Freeze kiya jaaye” (Lets freeze it)

    Am I the only one finding this correlation funny?!

    Closing Song: Swept away - Yanni.
    Closing Mood: The sun is up. Time for me to go down!

    Blog Entry Poster

    Posted in interesting, linux by ego on January 23rd, 2007

    Opening Mood: Yawn
    Opening song: None

    I upgraded to Ubuntu Edgy Eft. It’s awesome. Everything seems to be working just as expected. Found a lot of cool tools and features.

    Blog Entry poster is one of them.

    This post has been created using Blog Entry poster.

    Closing song: none.
    Closing Mood: Double Yawn