Monthly Archives: June 2013

Invisible Races

When you’re writing multi-threaded applications, the problem you are working hardest to avoid is that of data races. Here’s an example (assume a 32-bit x86 system): int global = 0; void thread1() { global += 1; } void thread2() { global = 0x10000; } The race here is pretty obvious. Two threads are accessing the… Read More »

Copy and Swap Idiom

I learned a new trick today, while reading about C++11 (of which more to come). It’s a technique I wish I’d known about a long time ago, as it addresses an issue I’ve always thought C++ had – forcing you to duplicate code. That issue is addressed even more thoroughly with C++11, which has introduced… Read More »

UNIX’s Achilles’ Heel I

UNIX has one (to my mind) big hole in its API. Windows, surprisingly, doesn’t share it. This article will discuss that gap, and how it can be worked around. File Descriptor Wakes There are a few multiplexing system calls, select(), poll(), and epoll() that put a thread to sleep, with the wakeup triggered by activity… Read More »

Android Authenticators I

I found a blog that gave an example of how to make a custom authenticator for Android. I didn’t find it very clear, so this article covers my understanding that I’ve pulled this together from the example given by that blog author, and from the Android documentation, and then building something that works. To make… Read More »