Newsgroups: comp.parallel.pvm
From: Jon King <kingjo@cs.orst.edu>
Reply-To: kingjo@cs.orst.edu
Subject: Re: shared in PVM
Organization: Oregon State University
Date: Fri, 08 Nov 1996 13:30:51 -0800
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <3283A68B.4B09@cs.orst.edu>

Cosso Nicosia wrote:
> 
> We are two italian students from Pisa University.
> We have some problem to make a variable shared between more tasks PVM
> so that the processes can read and increase it.
> We have thought to use the pvm_insert(), but how it possible to solve
> the mutual exclusion?
> 
> Thre is a way to share a array between more tasks PVM, excluding to
> use a  message passing?
> Thanks for our attention.
> 
> Massimo, Massimiliano.

I believe I used the following two functions to perform distributed
mutual exclusion with PVM.  Didn't go back and try them again, but give
it a shot.  

#define SEM "some_text_string"

void pvmP( )
{
  while( pvm_insert( SEM, 1, 1 ) == PvmDupEntry );
}

void pvmV( )
{
  pvm_delete( SEM, 1 );
}

They utilize the database as a semaphore to ensure that only one can
access the shared variable.  You might use this as follows:

	...
	pvmP();
	  // shared variable access here
	pvmV();
	...

Depending on the length of your critical section, you might not want to
have the waiting task continuously sending pvm_insert messages.

Although this is crude, I remember it working well.

Good luck.
Jon

