To do parallel processing..

R

rajendra

Hello All,

I would like to know is it possible to process the array elements while the
array itself if being updated(storing elements) using some parallel
processing technology in perl...

With Rgds,
Raj
 
M

Mumia W. (on aioe)

Hello All,

I would like to know is it possible to process the array elements while the
array itself if being updated(storing elements) using some parallel
processing technology in perl...

With Rgds,
Raj

From "perldoc perlsyn":
If any part of LIST is an array, "foreach" will get very confused if
you add or remove elements within the loop body, for example with
"splice". So don't do that.


Nonetheless it's probably possible depending upon the situation and the
program.

Since you didn't show any program, it's not possible for me to comment
further.
 
X

xhoster

rajendra said:
Hello All,

I would like to know is it possible to process the array elements while
the array itself if being updated(storing elements) using some parallel
processing technology in perl...

Not natively, but there are many ways to achieve effectively the same
thing. Maybe Thread::Queue would suit you.

Xho
 
T

Ted Zlatanov

I would like to know is it possible to process the array elements while the
array itself if being updated(storing elements) using some parallel
processing technology in perl...

If the update is only adding elements, you want a queue. Use shared
memory between two processes. IPC::ShareLite may work, for example.

collector process:
1) get new data
2) put new data at end of a list (the queue)
3) is the shared memory full? if yes, go to (1)
4) put the oldest data (at the beginning of the queue) in shared
memory
5) go to (1)

computational process:
1) is there new data in shared memory? if no, go to (1)
2) get new data and process it
3) empty shared memory

You can get much fancier, but this is probably enough to do what you
need. It's a basic "dropbox" method. Note it's not, by far, the only
way to manage data, but the key with parallel processing is to
simplify as much as possible. The simplest solution will work best; a
complex solution will be a nightmare to debug when bugs could be in 1
of N processes.

If you want more processing, increase the number of computational
processes and give each one a separate shared memory dropbox.

Ted
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,159
Latest member
SweetCalmCBDGummies
Top