Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Why not use IPC - semaphores, isn't it what they were created for? (Serializing access to limited resources?).
use IPC::SysV qw(IPC_PRIVATE S_IRWXU IPC_CREAT); use IPC::Semaphore; $sem = new IPC::Semaphore(IPC_PRIVATE, 10, S_IRWXU | IPC_CREAT); # and the crucial part: $sem->op($semaphoreNumber,0,0); # where first zero means wait-for-zero operation, # ie, your code will stop and wait (CPU-friendly) # until your semaphore becomes 0. #etc...

Why hasn't anyone suggested this yet?

This is a SolvedProblem(TM) in computer sciences, ...or maybe I'm missing something?

OTOH, I find spool-model generally more usefull, ie - you've got dedicated process for processing incoming jobs, and your workers just drop their jobs into a spool, be it directory, sql table or shared memory segment (I would recommend IPC::ShareLite).

This is the way mail servers, fax srvrs and many others work...

Why is everyone soo keen on using files when there are superior methods around? When it goes to synchronising jobs between multiple machines files are not that great either, you get multiple problems with most remote filesystems... on the other hand there are remote IPC solutions available and they are created and tested specifically to work with such scenarios.

I don't know if this is the case, but I usually have such feelings when interfacing with php/mysql people... they have no CS background or are unable to use it...ask the simplest questions about the basic things... and then proceed to solve them with strangest hoops... and THEN they warp the reality with their weight and make young programmers think that this is the right solution.


In reply to Re: Ways to sequence calls from multiple processes by Eyck
in thread Ways to sequence calls from multiple processes by johnnywang

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-26 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found