Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Efficient way to fork processes and keep a running count?

by JavaFan (Canon)
on Jan 27, 2010 at 23:24 UTC ( [id://820054]=note: print w/replies, xml ) Need Help??


in reply to Efficient way to fork processes and keep a running count?

There are several ways. The easiest is to assume reading each CD takes the same amount of time. Then each child reads 4 disks, and there's hardly any bookkeeping needed.

Otherwise, you could implement a simple queue - each child fetches the next number from the queue, reads that disk, and repeats until the queue is empty. You could use a file or a database table for the queue (remember to lock!). Or you could have the children read from a pipe.

Another idea is to have each child read one CD. If the CD has been read, the child terminates. Parent notices the child terminates (wait/waitpid) and forks a new one. New child should be passed both a drive and a CD number.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://820054]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-25 07:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found