## Saturday, July 30, 2005

### Foveon X3 Technology

If you are interested in digital photography, please read the Digital Camera FAQ. One very interesting feature is the Foveon X3 Technology.

Here are some images to show you the distinction, they have been taken from the Foveon site.

 Mosaic Capture Foveon X3 Capture

 Sharpness Mosaic [Larger View] Foveon X3

 Color Detail Mosaic [Larger View] Foveon X3

 Artifacts Mosaic [Larger View] Foveon X3

### Can you recognize this person?

She is very popular and you will find her in a lot of image processing books. There is a very interesting story and background about this person and her photograph. Can you figure it out? If you can't, please wait for the answer or ask for it

### Migrate apps from Internet Explorer to Mozilla

IBM is running an article on Migrating Internet applications to Mozilla.

Figure 3. Mozilla's JavaScript debugger

I found it very interesting as I try to learn more about where the web has gone since the CGI days. I love XML, its a big relief from SGML.

## Wednesday, July 27, 2005

### Open Solaris

I am very excited about open Solaris. With the Apple folks also deciding to move to an Intel platform, Intel users would have access to

1. Linux
2. FreeBSD/NetBSD/(other BSD clones)
3. Solaris
4. MAC-OS X (derived from darwin - open darwin)
5. Windows
The exciting thing is that sources for the first four can be easily obtained. Its fun to see gcc ported to all these platforms. All these are encouraging trends, the base support software is getting free, so will the other support tools in time to come. What will the software industry pay for then?

Lets see where the future takes us.

## Monday, July 25, 2005

### Conspiracy Theory - Did we land on the Moon?

Star world ran this program on Saturday 9:00 PM. It almost made me believe we did not land on the moon. Then I saw the http://www.braeunig.us/space/hoax.htm and I am a bit confused now by both claims.

NASA also has an interesting site http://science.nasa.gov/headlines/y2001/ast23feb_2.htm?list45245. I think I am going to believe again that we landed on the Moon until the next space vehicle to orbit the moon finds/proves that we did not go to the moon.

What I have found so far is that people believe strongly. A believer is not open to changing his mind and vice-versa.

## Friday, July 22, 2005

### Deterministic problem solving

Have you come across a problem that makes you want to wonder as to how long it will be before the problem will be solved. There are many good books out there on debugging and many many interesting discussions on weird problems and their solutions.

The question for today is

1. Can we come up with techniques to convert the solution time non-deterministic to deterministic?
2. How would be verify that these techniques do that effectively?

## Tuesday, July 19, 2005

### 1970 and 1979 Editions of "How it works, the computer"

Interesting book and its online now. I like the size of the computers. Slashdot also has this story here

### The Image Drawing Dilemma

Good posts demand good illustration. That is true for all topics but especially true for technical content (I know I promised more non-technical content, I have quite a bit of it, but it needs to be organized and reviewed).

I have been evaluating the following options for illustrating

1. Hand drawn (I have a scanner)
2. Using a tool like VISIO (openoffice has a decent tool too)
3. Using my favourite MetaPost/LaTeX/pdfLaTeX/MetaFun
4. Using PIC
5. Using Graphviz

In this post, lets look at hand drawn images. Here are two hand drawn and scanned images - what do you make of them?

## Monday, July 18, 2005

### Are you a computer engineer?

Do you recognize these symbols?

If you don't, I suggest you refresh your knowlegde again.

## Sunday, July 17, 2005

### The latest review

I just got an email from William Stallings telling me that the book is published. Since I am one of the technical reviewers of the book (single chapter), I am expecting my free copy soon.

I like books by Stallings, they are well written and well illustrated. This is one of my last reviews this year.

### Experiments with syntax highlighting

I have been posting code for a while now, I want to try and post good looking code - which is syntax highlighted.

Here is the first attempt

/* * Simple program to parse regular expressions * (C) Balbir Singh * Permission to copy the program if and only if the (C) is * maintained. */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <assert.h>#include <errno.h>#include <bitset>#include <iostream>#include <queue>using namespace std;static bool status = true;#ifdef DEBUG#define debug(x...) {\    printf("%s:%d ", __FUNCTION__, __LINE__); \    printf(x); \}#else#define debug(x...)#endif#define pcr debug("current token is %c\n", s[idx]);#define perr {\    fprintf(stderr, "%s:%d parse error at token is %c\n", \        __PRETTY_FUNCTION__, __LINE__, s[idx-1]); \    status = false; \};

## Saturday, July 16, 2005

### Supplementary software for Fedora core 4

I found this interesting http://www.cnam.fr/maths/Membres/wilk/InstallSupFC4.html I found it quite good, the web site recommends some add-ons after installing Fedora Core 4

## Thursday, July 14, 2005

A paper I wrote on locking several years ago. I reproduce it here in parts.

Elements of locking

Abstract:
In this paper we discuss the various aspects of locking, including designing code which would be considered safe. By safe, we mean free of unexpected side effects. These side effects are commonly known as race conditions in the literature of operating systems and computer architecture. Although a lot has been written on this subject, we will look at it from a different angle. Several examples have been used to illustrate the contents of this paper, the reader is not expected to understand the code listings and what the code does. The code should be viewed from the point of view of locking. The term locking has been used here to mean methods of protecting critical section of the code. It is assumed that the reader is familiar to some extent with the concept of critical section. Most of the examples and treatment of this subject is with respect to a operating system kernel concept, but the principles discussed here even apply to a multi-process or a multi-threaded user application. All the discussion applies to non-preemptive kernels only.

### The Need For Locking

The need for locking is simple and a lot has been written about it. We will use a pratical example of a race condition often seen in an operating system environment. We will take an example from fork.c in Linux, it is a small and good example.

down_write(&oldmm->mmap_sem);
retval = dup_mmap(mm);
up_write(&oldmm->mmap_sem);

The fork system call in Linux and other Unix variants does the following

Figure 1: The fork() system call

Now consider what could happen if we did not lock the address space of the parent using down_write(&oldmm->mmap_sem), the address space (see figure 1) of the parent could change and what we set out to do i.e, Ensure that parent and child have the same address space at the end of fork, would never be accomplished. The dup_mmap(mm) function duplicates the address space. The deletion of a single page could affect the system call if proper locking is not used. We call the data and code protected by the locks as critical section. In our case the data used by dup_mmap(mm) that is mm is our critical section.

A fundamental assumption of locking is - once we get the lock it is ok for us to go ahead and modify/use the data protected by the lock.

NOTE: Most of the new hardware and software developments demand more concurrency, as we head towards concurrency at various levels of hardware and software, the need for locking and sound locking design principles become more accute.

## Wednesday, July 13, 2005

### Interesting article on ICMP errors

Open BSD Hackathon 2005, Part III points out some interesting errors with ICMP.

## Saturday, July 09, 2005

### First Letter to Stroustrup

Hello, Bjarne,

I have been reading "The C++ Programming language, third edition (special edition)". Reading through section 11.3.2 made me realize that user defined types could use another feature like "type promotion" to get closer to types supported by the language. To support Mixed mode arithmetic the number of operators defined is 5 in section 11.3.2.

I was wondering if we have a promotion operator.

For example, lets say we have a reserved keyword promotion and we could do the following

Complex& operator promotion(double d)
{
this->im = 0;
this->re = d;
return *this;
}

The promotion operator could be invoked whenever we encounter a type in an operator that is not of the same class as the operator.

For example

2 + c // where c is complex

Could invoke a promotion operator with a new temporary created by the compiler

In effect, it would be equal to

t = new Complex();
c.operator+(t.operator promotion(2), c)

I think this would simpifly the permutations, combinations needed to develop a good usable user defined type.

Balbir

## Friday, July 08, 2005

### Compilers - where are they going?

Reading through some of my books, I came across two concepts that I think are the biggest things that compilers support today

1. Templates or Generics
2. Reflection

The diagram below depicts the following facts

1. Reflection is getting us closer to the compiler internals. They help us with how types are organized and to help us probe for more compiler details. Reflection is helping the user get more information about compiler internals.
2. Templates are taking us towards implementing our own primitives. We are so close to doing code generation using techniques like meta template programming.

The day is not far when templates and reflection techniques will merge at some point giving the user full control from compiler internals to using the compiler interface.

## Thursday, July 07, 2005

### Effective C++, Second Edition

If you have read Effective C++, Second Edition, I hope you enjoyed reading it. I have started reading it and found some interesting things, I reported them to Scott Meyers. He updated them at Effective C++, Second Edition, Errata Web site. My code name is bxs.

You can find what I said and some really interesting stuff that others have said at the above web site.

## Tuesday, July 05, 2005

### Whom should we encourage to become our next generation leaders?

I have been thinking about this issue for a while. Who would make a good leader in the Indian democracy? What background should they come from? Well, here are my thoughts so far

Lal Bahadur Shastry ji used the following slogan (Jai is a praise, kisan is a farmer, jawan is a soldier and vigyan is science)

Jai Jawan, Jai Kisan

to which Atal Bihari Vajpayee added

Jai Vigyan

I feel we need people from the defense in our parliament. America has had the tradition of having people serving in the military become their presidents. I feel we should have

1. Kisans (farmers) at the grass root level of politics
2. Vigyanis (Scientists) be involved as Members of Rajya Sabha (as already dictated by our constitution)
3. Jawans (Soldiers) at the top most level of leading the country with pride and loyalty.