Archive for June, 2005

Thread yield after mutex unlock?

Is is sensible to unlock a mutex and immediately re-lock it? Consider this example:

  while(1) {
      /* Do work. */

The intention here is to make other threads wait until we’ve finished doing work. Then we give them a chance to get in before we go round again and do more work. But can we guarantee that the scheduler will allow another thread to get in when we unlock a mutex? Is it possible that this thread will immediately re-lock the mutex, and never give other threads a chance to get in? Read the rest of this entry »


dig: segmentation fault on UML

The ‘Native Posix Thread Library’ (NPTL) is not supported by User Mode Linux (UML). NPTL is the much-vaunted ‘new’ threading implementation in the Linux 2.6.x kernels. There can be many symptoms of this problem, but the one I seem to always get is a crash whenever a program tries to resolve a host name. Whatever the symptoms, you will only see problems with a 2.6.x UML kernel – the same filesystem will work correctly when you boot it with a 2.4.x UML kernel.

The solution: Disable the new threading by renaming /lib/tls to /lib/tls.DISABLED on the guest, and reboot UML.

Although this solution is simple, it’s not permanent (at least on Debian). apt will continue to re-create the /lib/tls directory whenever it is updated. Then you’ll start to see crashes again when you next reboot.

Comments (2)

Object-Orientated JavaScript

Object-oriented JavaScript for the C++ programmer.

This article presents a bestiary of JavaScript constructs, set against their equivalent in C++. Most of the basic class and object tools are available in JavaScript, and the syntax is often recognisably similar. Read the rest of this entry »

Comments (11)

Xerces: Attribute already used

Today the Xerces XML parser gave me this bogus fatal error:

The attribute ‘aMixedCaseAttr’ is already used in element ‘anElement’

I was sure I’d seen it before, and sure enough it’s bugzilla bug #26627. Turns out it’s a bug in Xerces v2.4, It sometimes gives this error when the XML document contains mixed-case attributes. The only solution is to upgrade to a newer version.


The ‘Single Thread Model’ is useless.

Normally a CORBA application processes each request in its own thread. So the author of a CORBA servant must always be aware that their methods may be running concurrently in multiple threads. Critical sections must be identified and locked accordingly.

Multi-threaded programming can be quite a pain, and all that locking, unlocking and context-switching can be a drag on performance. The SINGLE_THREAD_MODEL seems to offer a way to escape all these worries. Sadly it doesn’t deliver on that promise. Read the rest of this entry »


Wake up America!

Anne Applebaum argues that Amnesty International is biased when they accuse the US government of human rights abuses. The truth is that Amnesty are neutral observers who tell it how they see it. It really worries me that Americans can blame the messenger but ignore the message.

Perhaps the USA’s violations of human rights are done with more media-savvy than Stalin or Mugabe managed. Perhaps they are better targeted at ‘them’ rather than ‘people like us’. They are no less wrong.

I fear that things are going to have to get a whole lot worse before they start getting better.