Tuesday, August 30, 2005

The Bus to the Peak on the Hong Kong Island

Ferry ride from Kwaloon to Hong Kong Island

The tower in Hong Kong

Saint ALP's Tea House - I took this Photo since the icon looks like the Gnome Icon. This is where I had lunch

Streets of Hong Kong -- on the way to the train terminal

A Chinese Chef making Indian Paratha

The team that I worked with in Shen Zhen

Shangri La -- My Hotel

On the way to the customs from Shen Zhen

Shopping Mall at the customs

Customs between Hong Kong and China

Monday, August 29, 2005

Learning(s) from a different land - I

Imagine my surprise when I went to a vendors office to help him out with some issues. The office had two rooms and a hall, a restroom and a small kitchen. The rooms were used for residential purposes. I was wondering if this is any kind of place to do business.

The hall had three phones (two cordless), a laptop for each person, one wireless and one wired router with a broadband connection. The engineers had all the stationary and used an oscilloscope for debugging. They also had soldering capability.

In the time to follow I began to love the work environment, no meeting, no interruptions, everyone has lunch together, the atmosphere was very informal almost like working from home. The kitchen had everything we needed to eat, we could walk around freely or rest on the sofa set. The environment made us feel so agile, we could solder up any hardware changes we needed, discuss any changes we wanted. I was glad to see that the Phone was not ringing, I had no chat interruptions, I did not have to wait for people for lunch. I had no fixed process to follow, no timesheet to fill, no status report to update, no meeting to attend.

I felt empowered to work the way things work for me. I got to define any workflow I wanted to follow to reach success. I realized that I was treated as per my capability and could decide what I needed to do. I was treated on Merit. We did not have any manager, just a stake holder.

I learnt that the ideal team size is probably 3 to 4 with no managers, just stake holders in the success of the team. This is probably what Agile Programming is all about, but to see it work is something else. I think organizations should ensure that like software, people should also have high cohesion and low coupling. I understand how the open source community works now.

Saturday, August 27, 2005

I'm back

Having spent a week in China/Hong Kong, I am back. I have some pictures, but I'll post them soon. I had a fun time in China and Hong Kong. Lots of learning(s), I hope to post them here as soon as I find free time.

Friday, August 19, 2005

Off for a while

I am off on an official visit for a week. I hope to be able to take my camera along and post some good pictures.

If you find the blog is not updated for a while, you know the reason. I will try to keep the blog up to date depending on the time I am able to find.

Wednesday, August 17, 2005

A new machine in my room


I hope I am able to use it well!

Late Night Help for a desperate photographer

I had taken some cool photographs using my digital camera. My previous installation of Windows 2000 had gone bad, so I reinstalled it. One of things that happened was that I misplaced my Cammedia software that comes with my camera. Olympus would not supply the software online. They asked me to contact an Olympus dealer.

Linux came in very handy, I was able to read my photographs using Digikam. See the screen shot below


I guess this is just one of the many good things about open source.

Check out digikam. Also check out the screen shots at Digikam ScreenShots

Tuesday, August 16, 2005

Searching with A9

Bored with the results returned by google. I decided to try out Amazon's search engine A9. I like the column based display of the search and the variety for selecting the source for searching.

One can dynamically select the source and select preferences. Books can be searched as well!

The screen shots below show the main page and a sample search for Discrete Cosine Transform. I found the search interesting. Many links were common between google and A9, but I think I am going to use A9 more often.


Home Page of A9.com


Search for discrete cosine transform

Monday, August 15, 2005

Real Time Preemption changes being planned for 2.6

Paul McKenney with whom I had a good time interacting in Sequent, has written a great article on Real Time Preemption at A Real Time preemption Overview

These changes obsolete many things that have been said about Locking in Linux. As they say in the open source world

"If there is a book on it, the topic is obsolete"

I would highly recommend reading this article

Friday, August 12, 2005

Opera 8 now

I use Opera once in a while. Some of the stuff is really good.

  1. Mouse Gestures
  2. Unix Like Browsing
  3. Voice Support
  4. Many more

but what I found very useful for my blogging is image scaling. Scaling down of images is much much better than IE or Firefox.

Image rendered by Opera 8

Image rendered by Firefox

Image rendered by Internet Explorer

Thursday, August 11, 2005

Compile Time Assertions

A friend and I got into a discussion in coffee day last night about a review he was busy with. The code he was reviewing converts an integer to string. The author was taking the value of the integer, calculating log10 of the number and adding 2 to it to calculate the length of the array for storing the converted string.

This array would then be malloc'ed to store the string.

There are obvious deficiencies in this code

It is slow (due to the log10 calculation and malloc)

on the other hand

This code would scale better than any other code, for example if the integer size of the platform changed.

I suggested that the author do the following

1. Calculate the maximum array size for an int of 4 bytes (remember to include space for a possible "-"). Currently (11+1(possible "-")+1 ('\0' character)) bytes for a 4 byte integer.
2. Use compile time assertion to assert the size of the integer being converted.

If you are wondering what compile time assertions do, look at the code below

1 #define CT_ASSERT(cond, msg) \
2 typedef char msg[(cond) ? 1 : -1]
4 int
5 main(void)
6 {
7 int i = 10;
9 CT_ASSERT(sizeof(i) == 4, size_must_be_4);
11 }

Compile time assertions try to use the preprocessor and create situations that are illegal. The "C" compiler cannot compile the preprocessed code, if the assertion fails. See the example above.

On a platform where this condition fails, the output would be

cassert.c: In function `main':
cassert.c:9: size of array `size_must_be_4' is negative

This ensures that there is no runtime overhead of catching assertions and yet the code is fast and will break if the size of the integer changes.

Other sources of information
  1. Catching errors early with compile-time assertions
  2. Compile Time Assertions in C

Monday, August 08, 2005

Netscape 8 is such a joy

After all the controversy surrounding Netscape 8. I decided to install an upgraded/fixed version of Netscape 8. I found it amazing, you can switch between the IE and Firefox rendering engines so easily. I think this a big boon for web developers who are faced with the difficult task of testing pages with both browsers.

In the screen shots below look at the icon at the bottom left of the screen, they show the icon with which the page has been rendered. I think this a giant step for web developers and a good move by Netscape.

Netscape rendering using Firefox Posted by Picasa

Netscape rendering using IE Posted by Picasa

Netscape used to be the only browser for Linux, but unfortunately they have decided not to release Netscape 8 for Linux. I would be happy even if they released with a firefox engine, atleast I would use the same browser across platforms.

Sunday, August 07, 2005


Do you enjoy wikipedia? Well there is a good celebopedia web site now. Each celebrity is listed with news, biography, stats, media and some extras. So will celebopedia become a standard like imdb.

I still love imdb and I think its much ahead of celebopedia.

Friday, August 05, 2005

An unexpected visit

On one of my posts, I found a post from two people who decided to visit other blogs and leave behind a visit me message. I think that's cool, but where does one draw the line?

Well, to be fair, I visited their web site from home and found out something about them. Blog's are multi-dimensional (people might not be willing to show all aspects of themselves completely). Some blogs are personal, some are political, some are technical, etc. Some blogs have mixed content.

I use the blog's I read column to link to my friends, but I might start indicating what kind of blogs I would like my blog to be linked with. The blogosphere is similar to a biological system. Wikipedia's definition of Blogosphere is very interesting.

Wikipedia states

Blogosphere (alternate: blogsphere) is the collective term encompassing all weblogs or blogs as a community or social network. Many weblogs are densely interconnected; bloggers read others' blogs, link to them, reference them in their own writing, and post comments on each others' blogs. Because of this, the interconnected blogs have grown their own culture.

Blogosphere is an essential concept for blogs. Blogs themselves are just web formats, whereas the blogosphere is a social phenomenon. What really differentiates blogs from webpages, forums, or chatrooms is that blogs can be part of that shifting Internet-wide social network.

Like biological systems, the blogosphere demonstrates all the classic ecological patterns: predators and prey, evolution and emergence, natural selection and adaptation. The number of links obtained by a blog, is frequently related to the quality and quantity of information presented by that blog. That means, the most popular blogs have the highest link level, the worst blogs have the lowest link level. The blog ecosystem has its own selection and adaptation mechanism. The good tends to become better, the bad tends to disappear.

Through links and commentaries, the blogosphere with its self-perfecting mechanism, converts itself from a personal publishing system into a collaborative publishing system.

I don't want to disappear, please help me survive :-)

Thursday, August 04, 2005

Can you recognize this person? -- Answered

Here is the answer to Can you recognize this person?. The name of the person is Lena.

See this expert from an email response

Subject: Lena (parting words) (longish)
Date: 21 Feb 1996 13:33:20 GMT
From: dobelman@dfw.dfw.net (John Dobelman)
Organization: DFW Internet Services - DFWNet: 800-2-DFWNet
Newsgroups: sci.image.processing

If Dr. Munson and the Transactions can forgive the copyright infringment, the departing Editor-in-chief's comments on the Lena deal are too good not to share with the group.


A Note on Lena

During my term as Editor-in-Chief, I was approached a number of times with the suggestion that the IEEE TRANSACTIONS ON IMAGE PROCESSING should consider banning the use of the image of Lena. For those of you who are uninitiated in this brouhaha, let me provide a few facts. The original Lena image was a photograph of a Swedish woman named Lena Sjooblom, which appeared in the November 1972 issue of Playboy Magazine. (In English, Lena is sometimes spelled Lenna, to encourage proper pronunciation.) The image was later digitized at the University of Southern California as one of many possible images for use by the research community. I think it is safe to assume that the Lena image became a standard in our "industry" for two reasons. First, the image contains a nice mixture of detail, flat regions, shading, and texture that do a good job of testing various image processing algorithms. It is a good test image! Second, the Lena image is a picture of an attractive woman. It is not surprising that the (mostly male) image processing research community gravitated toward an image that they found attractive

An interesting link is http://www.lenna.org/

Wednesday, August 03, 2005

Rock star INXS

Do you guys watch the show on Star World! Well, I love the show.

  1. http://rockstar.msn.com/
  2. http://www.cbs.com/primetime/rock_star/

I love Jessica's attitude and singing. But my picks for the top three are

The photographs have been taken from rockstar.msn.com

What to Lock (Locking Design part IV)

To discuss this, we first need to look at what kind of system architecture is being used. There are two special types of locking primitives, they are described below.

  • Semaphore

    A semaphore is used to denote a locking primitive in which we relinquish the CPU if we do not get the lock. In the examples used in the previous article, down, down_write and down_interruptible are semaphores. The pseudo code for a typical semaphore implementation is given below.

    \begin{algorithm} % latex2html id marker 53\caption{Psuedo code for a semaphor... ... queue} \STATE return with the lock held \ENDIF \end{algorithmic}\end{algorithm}

  • Spinlock

    A spinlock is used in a multiprocessor environment. There might be cases when one cannot go to sleep waiting for a lock. Consider for example an interrupt handler in a Symmetric Multi Processing environment (here after referred to as SMP). All the CPUs may receive an interrupt from any device. If a device interrupted the system twice, lets say one interrupt goes to CPU 1 and the other to CPU 2. Both of them execute the same interrupt handler for the device. They will need mutual exclusion to avoid the kind of races or unexpected results. It would be very bad for a CPU to go to sleep in an interrupt handler, because an interrupt handler is running at a very high priority, preempting everything else, we should deal with it quickly or the system will perform very badly. So what do we do, we spin on the lock being held by the other CPU (assuming that the other CPU will not hold the lock for long). Once we get it, we finish with the interrupt handler and continue (NOTE: The assumption here is that interrupt handlers run fast, otherwise the spinlock will spin for a long time).

    \begin{algorithm} % latex2html id marker 63\caption{Psuedo code for a spinlock... ...TATE return with the lock held \ENDIF \ENDWHILE \end{algorithmic}\end{algorithm}

Now that we have looked at kinds of locking primitives, let us discuss when we need to lock data. First of all remember that we need to lock only global variables and structures, since only they are prone to races. Local variables reside on the stack and since each process on each processor has its own stack, there are no race conditions with local variables. We will consider the following cases

Rules Of Locking (locking design part III)

The rules are listed below

  • Lock only data, not code.
  • Lock only what you want to protect, not everything around it. Use locking optimally.

Surprisingly enough, there are only two small rules for locking. These rules are definitely not exhaustive, they are rules of thumb and form the basis of this article. From these rules we will draw more and try to use real world examples to illustrate the various rules. Lets now see what each rule means.

     /* Find the cache in the chain of caches. */
/* the chain is never empty, cache_cache
is never destroyed */
if (clock_searchp == cachep)
clock_searchp =
kmem_cache_t, next);

if (__kmem_cache_shrink(cachep)) {
printk(KERN_ERR "kmem_cache_destroy:
Can't free all objects %p\n", cachep);
return 1;

In the example above, we grab the cache_chain_sem lock twice. We release the lock before calling __kmem_cache_shrink() and grab it again if necessary i.e, if __kmem_cache_shrink() returns a value greater than zero. We could have held the lock for the entire duration and freed it at the end, but it would conflict with the rules we stated above.

We would be protecting code and not data, we need to protect the cachep list, so we use the lock only to protect the contents of that list from changing. What if we held the lock and __kmem_cache_shrink() turned out to be an extremely long function? Other routines waiting for that lock would really starve, especially if __kmem_cache_shrink() does not change the cachep list. It would even be unfair to hold the lock and make merry while others are waiting for the lock.

This brings us to some important questions

  1. When do I need to implement locking into my code?
  2. How do I design my code to in corporate locking into it?

These questions are answered in the articles to follow.

Monday, August 01, 2005

Pages related to OSX86

Apple has decided to move to the intel platform. Here are some links related to their effort

  1. http://www.osx86.classicbeta.com/wiki/index.php/Main_Page
  2. http://maconintel.com/
  3. http://www.appleinsider.com/article.php?id=1175
  4. http://www.macsimumnews.com/index.php/archive/
  5. http://buildyourownmac.com/
  6. http://www.jbnahan.net/en/
They are all unofficial, but they are fun to read. I can't wait for my own copy of MAC-OS-X on Intel or to buy one of those cool boxes. I hope they use a processor with 64 bit extensions and hyper-threading support