[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.programming.threads

Threads or processes?

unknown

8/6/2004 10:17:00 AM

I've got an existing multi-threaded app (App0), which has about 10-20
communicating (p)threads, sharing common resources. I've now got to
extend this. Basically, I've got to take the entire application, and
duplicate it, maybe 5 or 10 times (say, App[1..5] instead of App0).

In the new system, AppN has its own local resources, and it works in
the same way as the existing code: it has about 10-20 threads all
accessing AppN's local resources. The difference in the new system is
that App[1..5] must all run in parallel. App[1..5] are basically
independent, except that there must be a relatively small amount of
communication between AppN <-> AppM. In many cases, this communication
will be trivial - sending a command and getting a result - but
sometimes it will be more complex, requiring a shared memory buffer
between the two.

I'm not quite sure how to start this - should I have a single process
with 5x20 threads, or should I create 5 processes, each with 20
threads, and some IPC mechanism? ie.

A) Write a new top-level that pthread_create's App0 five times over,
or

B) Write a new top-level that creates 5 processes, running App0 in
each process

A couple of other things:

1) The existing code only runs on a single processor (x86), and I'd
like the new code to run on multi-processor systems (Linux/x86 and
SunOS/SPARC) - does the choice of threads/processes affect this?

2) Not all of my existing code (ie. App0) is thread-safe, so solution
(A) requires some work

3) I don't know any multi-process IPC mechanisms - can anyone
recommend one, if (B) is the way to go?

Thanks -

Richard