Newsgroups: comp.parallel.pvm
From: Graham Nash <gnash@ncube.com>
Subject: Re: Help: How many messages to consume?
Organization: Integratek
Date: Mon, 29 Apr 1996 21:25:43 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <Dqn7Iv.J9v@ncube.com>

Vladimir Vlasov <vlad@it.kth.se> wrote:
>
>How can I get (from a PVM task) a number of messages
>(with any tag, from any task) waiting to be consumed
>(received) by the task?
>
>I would like to have something like:
>
>	nm = get_number_of_messages_to_consume(); /* ??? */
>	for (i = 0; i < nm; i++) {
>		pvm_recv(-1, -1);
>		/* unpack and process */
>		...
>	}
>
>Here: "nm", number of messages, guarantees that this
>task is not blocked on pvm_recv. So, the problem is to
>"get_number_of_messages_to_consume".
>
You could of course do this slightly differently:
	while ((bufid = pvm_nrecv(-1, -1)) > 0) {
		pvm_bufinfo(bufid, ....);
		/* unpack and process */
	}
pvm_nrecv returns immediately if there are no messages to consume. You
could use pvm_probe with a similar aim.

Alternatively, you could try some freaky stuff by substituting for the
comparison function:
	old = pvm_recv(myfunc);
where
	myfunc is called with args: (bufid, tid, tag) for each internally
	stored message. Thus you can count them, erase them, do
	anything you want in fact.

Hope this helps

Graham Nash


