I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2012-05-30 00:10:56.02973-07 by noop
Array Hash of semaphores
Hi all,
sorry if this has been answered before, but I couldn't find any information about the problem.
I'm using the following modules and versions:

threads : 1.86
threads::shared : 1.4
Thread::Queue : 2.00

I like to use a boss/worker model to process performance measurements. Thread 0 receives meas and pushes it to a Queue. Worker threads pop the incoming records from the queue parses them and stores the essential part in a file (RRD to be more concrete).

To protect each file used to store the meas (during the update) I created a Semaphore associated with the file. A global (anonymous) array stores the semaphores. Association is via common array index.

What I observe that each worker thread has an own copy of the thread objects (actually works like designed for thread module). Anyway the protection of the critical sections doesn't work. After some time there's a simultaneous access of the RRD file and the script terminates with SEGV.

Does anyone made has a workaround for this. Many thanks in advance for any hint...

Cheers
-Frank Heckes

Btw. I tried some similar mechanism creating lockfiles associated with each RRD, sysopen lock file, store filehandle in array and using flock to protect the critical section. Here each thread has an own copy of the filehandles, too and flock seems to fail, i.e. script dies again with segmentation violation after some time.
Direct Responses: Write a response