20080925

Debugging child processes

Problem:
Program A executes program B.
You want to debug program B.
B exits before you can attach your debugger.

Solution:
Insert an infinite loop in main() in program B:

while(1) {}

Run program A.
Attach debugger to program B.
Set the program counter to the next line:

In gdb, use the "jump" command.
In Visual Studio, use the "Set next statement" command on the context menu.

20080917

My First YouTube video



I used kino to edit the video and speed up the middle bit. The audio was a bit noisy after the speedup, but after exporting to FLV the audio had disappeared anyway.

20080915

Energy Saving Mobile Phone Charger


On the BBC Click programme on 20080711 they mentioned an "Energy saving charger" for mobile phones.

It's a plug in phone charger that only uses power when there is a phone connected to it.
It works by having a switch that is activated by the weight of the phone - no phone = no power.

Sounds like a great idea, but is it?

In computing there is a saying "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil."

Which basically means, measure the problem and attack the worst bit, as it may not be the bit you thought it was.

I've measured the power usage of a mobile phone charger with no phone attached, using a power meter between the device and the mains.
It was 0W.

The Phone chargers - the truth website found the same -
My measurements indicate that my phone chargers consume less than 0.5W when left plugged in. The total power consumption of the average Brit is 5000W. (Including car driving, home heating, and so forth, not just electricity.) So obeying the BBC's advice, always unplug the phone charger, could potentially reduce British energy consumption by one hundredth of one percent (if only people would do it).
Mobile phone chargers are not a major contributor to energy waste.

Don't waste your money on an "Energy Saving Charger".

20080914

Lucky Frog

I mowed the lawn today, and when I was putting the grass cuttings in our green bin I spotted a small frog.

It had somehow survived being mown over and was sucked up with the grass.

Clair decided to call it "Lucky".

We've put it in the pond.

20080913

Asymmetrical Bodies

When I buy spectacles, they make each lens to correct the eyesight in the eye it will be in front of.

Why do we have to buy a pair of shoes?
Wouldn't it be better to buy 2 shoes in the same style, each perfectly sized for the respective foot?

Why aren't bras sold as left cups and right cups, with a clip front and back?

Google Chrome

My first experience of a web browser was on the Amiga - IBrowse, AWeb and Voyager.
Computers in those days were so slow that you could watch the images on the page decompress line by line.
I didn't actually have internet access at the time, so I was viewing web sites that came on a CDROM with a computer magazine.

Eventually we got dial-up internet access, at 33kbps.
Although the PC could now decompress the images quickly, they didn't arrive quickly from the internet.
I'd open several web pages in separate windows, so that I could read one page while the others were downloading.

Tabbed browsing made this a much nicer, as it was much quicker to open a tab than a window.

Now that we have broadband, the pages don't take long to download, but I still use lots of tabs with gmail and bloglines open most of the time.

Browser memory usage has become an issue, as the web browser is no longer an application that is opened, used and then closed. It's now open all day. When an application is using lots of memory, it doesn't all fit in RAM at the same time, so the operating system has to swap some of it to disk and read it back later. The disk is much slower than RAM, so this slows the whole computer down.

Firefox 3 has made some great improvements in memory usage, but as it's written in C++, it is unable to use a compacting garbage collector that moves objects around, so the memory gets fragmented.

Google Chrome is avoiding this problem by having a process per tab. Freeing all the memory used by a process is very simple, just terminate the process.
I hope that this hasn't resulted in it being slow to open a tab.

I can't wait to try Google Chrome when it is released for Linux.

Time for a new blog

It looks like dslinux.org has died, so I'm starting a new blog here.

I haven't done any DSLinux development for ages, so don't expect to see DSLinux related posts here.