Newsgroups: comp.parallel.pvm
From: Ken Lancaster <ken@wynde.com>
Subject: Waiting process consumes processor time !?
Organization: Rocky Mountain Internet Inc.
Date: 17 Oct 1995 16:53:35 GMT
Mime-Version: 1.0
Content-Type: multipart/mixed; oundary="-------------------------------2050726593172476887025733543"
Message-ID: <460n2f$f65@natasha.rmii.com>

This is a multi-part message in MIME format.

---------------------------------2050726593172476887025733543
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii

I am currently developing a PVM-based application in C on a SUN Sparc 10.

I've coded up the executives for two of the processes in my application,
using a master/slave model.  At this stage in their evolution, the two 
programs are incredibly simple.  The master enrolls in PVM (pvm_mytid), 
and spawns the slave (pvm_spawn).  The slave checks it's tid (pvm_mytid), 
and then waits for a message (any message, i.e. pvm_recv(-1, -1) ).

The problem I'm having is that when the slave executes pvm_recv, instead
of going to sleep (like a nice little process), it starts "spinning", i.e.
consuming processor time, to the tune of 100% of one of the processors on 
the host ... it brings a SPARC 10 to it's knees just waiting for a message !

I ran the slave in a debugger, and determined that the slave is spinning 
in a (pvm ?) routine called peer_wait ... I don't have source code for 
peer_wait, so I'm not sure exactly what it's doing, but whatever it's
doing, it's doing it A LOT !

I went back and re-ran the hello / hello_other example programs, and they
do NOT exhibit the same behavior, i.e. when hello executes pvm_recv(-1,-1),
it actually goes to sleep until it receives a message, and does NOT consume
processor time.

Has anyone else experienced a similar problem ?  Any help would be greatly
appreciated.

Ken Lancaster
ken@wynde.com
Boulder, CO (USA)

p.s.  There is another piece to the puzzle.  The master, in this case, is
a TCL/TK based GUI, and performs the steps described above (i.e. enrolls
in PVM and spawns the slave) in response to a button click.   I do NOT
believe this is significant however, because the slave exhibits the 
same processor-consuming behavior even if you spawn it directly from the
PVM console, without the master running.

p.s.s. I will attempt to attach a copy of the source code for the 
slave to this posting, BUT I'm not very Netscape literate, and have 
hade problems "attaching" documents in the past.

---------------------------------2050726593172476887025733543
Content-Transfer-Encoding: 7bit
Content-Type: text/plain

/*
	Copyright (c) 1995 Wyndemere Incorporated
	All Rights Reserved -- %Z%%M% %I% %G%
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "pvm3.h"
#include "rundmc.h"

void 
main()
{

	int             nRunDMCTaskId, nPVMResult, nPVMBuffNum, nMsgSize,
	                nMsgTag, nSenderTaskId;

	nRunDMCTaskId = pvm_mytid();
	DPRINTF(("RunDMC: RunDMC enrolled ... nRunDMCTaskId = %i\n", nRunDMCTaskId));
	nPVMBuffNum = pvm_recv(-1, -1);
	pvm_bufinfo(nPVMBuffNum, &nMsgSize, &nMsgTag, &nSenderTaskId);
	DPRINTF(("RunDMC: %i bytes received from %i.\n", nMsgSize, nSenderTaskId));

}

---------------------------------2050726593172476887025733543--

