Profile

unixronin: Galen the technomage, from Babylon 5: Crusade (Default)
Unixronin

December 2012

S M T W T F S
      1
2345678
9101112131415
16171819202122
23242526272829
3031     

Most Popular Tags

Expand Cut Tags

No cut tags

March 16th, 2011

unixronin: Lion facepalm (Facepalm)
Wednesday, March 16th, 2011 09:03 am

If you develop code, you're gonna love this.

I have a multi-threaded Perl ICB client that I wrote.  I've always had an occasional problem with a race condition between different threads trying to write simultaneously to the screen.  I thought I had it solved at one point, but all hell broke loose after I built a new babylon5 with a six-core processor.  I tried various approaches to solve it, including meticulous use of Thread::Semaphore.

Well, I think I've finally solved the problem this time, by using a simple shared scalar as a semaphore and using lock($sem) instead of using a Thread::Semaphore object and $sem->down()/$sem->up() calls.  But, the ironic, yet inescapable conclusion from this...?

Thread::Semaphore isn't thread-safe.

Tags: