Those Pesky Applications!

January 26, 2010

Regardless of which operating you’re using, you’re bound to encounter applications that cause you problems. Some applications cause you problems so often that you eventually place a custom launcher or even a keyboard short-cut to a command that kills the applications. Firefox used to be one, but since version 3, it’s been much better. I still have problems, though now it’s always related to the Flash plug-in (which is rather troublesome in 64 bits mode). Another one that cause me problems regularly, is EvilEvolution, the Exchange client for Linux.


One essential *nix command you should know, is kill. The kill command dispatches a signal to a process, by default, SIGTERM. This message instructs the process to terminate. It can ignore the signal, but in general, it will close gracefully after freeing resources. If the program ignores the signal or is in an unstable state, you can kill it “harder” by using kill -9, which sends the process an unmaskable SIGKILL. The process terminates instantly under most circumstances.

Read the rest of this entry »

Bundling Memory Accesses (Part I)

January 19, 2010

There’s always a question whether having “more bits” in a CPU will help. Is 64 bits better than 16? If so, how? Is it only that you have bigger integers to count further? Or maybe more accessible memory? Well, quite obviously, being able to address a larger memory or performing arithmetic on larger number is quite useful because, well, 640KB isn’t all that much, and counting on 16 bits doesn’t get your that far.

AMD Phenom

But there are other advantages to using the widest registers available for computation. Often, algorithms that scan the memory using only small chunks—like bytes or words—can be sped up quite a bit using bundled reads/writes. Let us see how.

Read the rest of this entry »

Why Validating Input so Hard in C?

January 12, 2010

Validating input from file or keyboard is probably the most difficult thing to get right in C. Not only is it difficult to get right regardless of the programming language, C really doesn’t do much to help you. There’s the standard library, mostly accessible through the two headers <stdlib.h> and <stdio.h>. However, the facilities provided by the C library are rustic at best. They haven’t aged well, and they’re clunky.


For this post, I will limit I/O validation to grabbing input from text files, whether through a redirection, pipe, file, or console input. I may discuss binary or highly structured formats like XML in a later post, but let us first limit ourselves to a few simple cases.

Read the rest of this entry »

Stir Fried Stupid

January 5, 2010

A well structured library will contain functions that are grouped together in a same logical unit to help you perform a set of tasks more easily. This could be reading graphics files, or managing time and dates. Good libraries include just enough functions so that you have access to the complete functionality, but nothing superfluous.

Too often, libraries catch featuritis and grow large with less used functions that were added at some point to scratch a minor hitch. Worst, you discover functions hidden in a library that you’re not sure what to do with them, but sometimes, you find functions that are positively stupid. What is even more surprising is where you can find them. I found a couple in the GNU C Library.

Read the rest of this entry »