First open sourced project…

You got to watch this video in HQ mode…

I wrote this tool to explore GUI design with wxpython and data analysis with pandas. Nothing complicated. Bunch of lines in the is the workhorse. I could have also taken the pandas code and posted it as a script that one can run in ipython. But then, I threw a GUI in for fun. Now, that I think it can have serious uses, I will be working on packaging the tool and coming out with installers for multiple OSes.

rar, password and movie files

During my hunt for the anime movie ghost in the shell, I downloaded a ‘rar’ed  file. I found out after the download, that it was password protected. I did not expect that. But there it was, 700 MB file in my system but I could not use it. I decided that I would let a brute force password cracker run on it for as long as it wants. But my madness for the anime got over me and I stopped the software in an hour. I remembered that while trying to unrar, the entire movie file was getting extracted . The important fact is that the entire file is extracted. I just had to find a way to stop it from getting removed. For my purpose, it did not matter why it was extracting the entire file. We know it has to use some system call to remove the file. With that knowledge, I ran unrar under gdb and inserted breakpoints at remove and unlink system calls. And, my luck, the breakpoint was hit! I could see the entire file sitting in my directory waiting for it to get copied before rar removes it.

Unfortunately the movie was in japanese without any subtitles. I had to start the search all over again.

Kudremukh, Calvin and Kernel Crash…

The trek was awesome! Started on 14th night and reached Hornadu the next day early morning. The roads got lots of twists and turns. So many curves that some of the more stable guys puked. Hornadu has the Annapoorneshwari temple. Just like the Kollur temple stop when going to Kodachadri. We had breakfast there at the temple. The deity name implied that we should have breakfast there! From there went to kalasa and then to Balagal by bus. From Balagal, we decided to take a seven kilometere walk to mullodi. We had earlier planned to take a jeep, but the guy asked for 450 rupees. That makes it over 50 rupees per liter. Phew. Though we were seven, we decided otherwise. One should reach mullodi before 4 pm, if you take the same means of transport as we did.

We stayed at a house that was very close to a big stream were we could bathe. From there on, the kudremukh peak was 12 km. So it was a 24 km in a day trek. We trekked on 15th. No leeches this time since there was no rain for 2 weeks. Hence the journey was close to what we had in Mulainagiri. But the view that we got here was awesome. Along the route, one crosses several mountains of considerable height. But when you sit at the Kudremukh peak and look down, those same peaks look tiny, hiding behind the clouds. My head did spin a bit. We chose to sit as close to the edge as we can and it was like hanging from a rope at 1458 meters above sea level. I need to do a bungee jump an sky dive soon.

Calvin and Hobbes.. that kid is ultra smart!

Sometime back, I used to have tough time tracing the caller functions for a given function in the kernel. A colleague of mine had this simple way of doing it. Just create a null pointer exception at the called function and look at the kernel dump stack trace. You get what you want, i.e. the function that called this one. Not that its a great idea, but the fact is that its simple. It is right there and you don’t see it. Why make things complicated than they actually are?

Thrash The Cache

I did some experiments some time back on Icache. Putting down something one can try easily and yeah, its fun!

First of all, get the Icache size of your processor. You can get it by running dmidecode in your linux box (Yeah, I am assuming you are using linux). Example: `dmidecode | grep -B 20 way`.

Next see the associativity of your cache. On my system, its 4 way and the output looks something like this:

Operational Mode: Write Back
Location: Internal
Installed Size: 32 KB
Maximum Size: 32 KB
Associativity: 4-way Set-associative

So each address of my cache can be mapped simultaneously to four addresses in RAM at 32K fixed offsets.
As the topic says, lets thrash the cache. For that, we need to make sure that our instructions are aligned such that every 32Kth location in the memory is accessed. The following code does it for 1-way cache. Writing for 4-way would be lengthy and redudant code. So chose 1-way.

asm(“.space 32*1024 \n”);

Here asm(“.space 32*1024 \n”) makes sure that function func4 is spaced at 32K from func5. Run`nm | grep func` to get the addresses. Call func4 in a large loop and time the whole code. Now remove temp3 and look at the execution time. It takes a lot less time than that with temp3 (Increase the number of times the function is called to see the effect ). Mine is 4-way, So I need eight such functions spaced apart to start the thrash! The fun here is to see it happening after getting to read about it in books. Seeing it work is exhilarating. Try it and yeah…..Happy thrashing!

Yeah, this also gives the ideal ‘what not to do’ for writing code.