Newsgroups: comp.parallel.pvm
From: ambati@apollo.HP.COM (Ashok Ambati)
Subject: Re: DIRECT ROUTING HELP! HELP!
Organization: Hewlett-Packard Company, Chelmsford, MA
Date: Tue, 31 Jan 1995 14:50:08 GMT
Message-ID: <D39yJL.4B3@apollo.hp.com>

In article <3gcp4p$n5r@alpha.cisi.unige.it>, pvm@hp720.dibe.unige.it () writes:
|> 
|> Hy, I have a big PVM_problem!
|> I have build an master-slave alghoritm, based on PVM 3.3.6, and I need
|> to do message passing from master to slave while master do other operations.
|> This is a short example of what my program do:
|> 
|> 
|> /***** MASTER *****/
|> 
|> void main(void)
|> 	{
|> 	pvm_setopt(PvmRoute, PvmRouteDirect);
|> 	master_spawn_task();
|> 	if(fork()==0)
|> 		{
|> 		send_data_to_slave();
|> 		exit(0);
|> 		}
|> 	master_do_other_work();
|> 
|> 	recv_results_from_slave();
|> 	}
At this stage, the master has established a connection with the local pvmd and 
the forked child inherits it. So it is able to use the existing socket to the 
local pvmd to establish connections with the slaves and send data to them. Then
the forked child exits, causing the direct sockets to the slave tasks to be
closed.
|> 
|> 
|> 
|> /***** SLAVE *****/
|> 
|> void main(void)
|> 	{
|> 	pvm_setopt(PvmRoute, PvmRouteDirect);
|> 	recv_data_from_master();
|> 	slave_do_work();
By this time, the forked child at the master has exited and hence closed all 
direct sockets to the slaves. So the next operation will fail.
|> 	send_results_to_master();
|> 	}
|> 
|> 
|> The problem is that I want to use PvmRoute=PvmRouteDirect: it
|> happens that slave receive data correctly but it die when is the
|> moment to send results to master (PvmAutoError=2 and the program 
|> fails the same with or without the exit(0) in fork()).
|> Why? What is the solution?
One solution is to have the master set up the direct connections with the slave
tasks first. This can be done by the master sending a message to each slave. The
direct connection will be established as a result. Then the master can fork and
have the forked child send data to the slaves while it does other work.
However, I am not sure if PVM messaging was intended to be used in this fashion.
|> 
|> 
|> THANKS TO ANYONE
|> 	Marco

