TRECV(3PVM)
π TRECV(3PVM) π
okay bestie, welcome to TRECV from the PVM Version 3.4 manual set β yes, the 3PVM section, we're doing real parallel-computing lore today β¨
πΈ NAME πΈ
pvm_trecv β receive with a timeout, bestie. that's it, that's the whole vibe π
β¨ SYNOPSIS β¨
C girlies:
#include <sys/time.h>
int bufid = pvm_trecv( int tid, int msgtag, struct timeval *tmout )
Fortran girlies:
call pvmftrecv( tid, msgtag, sec, usec, bufid )
π¦ PARAMETERS π¦
tidβ an integer, matches the task identifier of whoever's sending you stuff πmsgtagβ an integer that matches the message tag. should be>= 0, no cap πtmoutβ (or, in Fortran,secandusec) how long you're willing to wait before just giving up and returning with no message. it's giving patience, but make it a limit π°οΈbufidβ an integer that returns the value of the new active receive buffer identifier. anything less than zero means something went wrong π
π DESCRIPTION π
so like, pvm_trecv blocks the process until a message with the label msgtag shows up from tid. no message, no movement. it's main character energy, it waits π
once that message arrives, pvm_trecv drops it into a new active receive buffer β and yes, it also clears the current receive buffer, out with the old π§Ή
but if no matching message arrives within the waiting time you gave it? pvm_trecv just returns without a message. no drama, no message, we move π«Ά
now the fun part: a -1 in msgtag or tid matches anything. wildcard queen π which gives you these options:
- if
tid = -1, thenpvm_trecvwill accept a message from any process which has a matchingmsgtag. - if
msgtag = -1, thenpvm_trecvwill accept any message that is sent from processtid. - if
tidandmsgtagare both-1, thenpvm_trecvwill accept any message from any process. literally anything, we're not picky π
in C, the tmout fields tv_sec and tv_usec specify how long pvm_trecv will wait without returning a matching message. in Fortran, two separate parameters, sec and usec, are passed instead. set both to zero and pvm_trecv behaves the same as pvm_nrecv β which is to probe for messages and return immediately even if none are matched. not me waiting zero seconds, respectfully π
in C, passing a null pointer in tmout makes pvm_trecv act like pvm_recv, that is, it will wait indefinitely. in Fortran, setting sec to -1 has the same effect. forever girlies, we ride at dawn π
β the message order tea β
the PVM model guarantees the following about message order, and this is important so listen up:
if task 1 sends message A to task 2, then task 1 sends message B to task 2, message A will arrive at task 2 before message B. first in, first out, we love a queue that respects itself π
moreover, if both messages arrive before task 2 does a receive, then a wildcard receive will always return message A. no cap, that's guaranteed π₯
π what you get back π
- if
pvm_trecvis successful,bufidwill be the new active receive buffer identifier β¨ - if no message is received,
pvm_trecvreturns0π«₯ - if some error occurs then
bufidwill be< 0π
once pvm_trecv returns, the data in the message can be unpacked into the user's memory using the unpack routines. go get your data bestie π
π EXAMPLES π
C:
struct timeval tmout;
tid = pvm_parent();
msgtag = 4 ;
tmout.tv_sec = 60;
tmout.tv_usec = 0;
if ((bufid = pvm_trecv( tid, msgtag, &tmout )) > 0) {
pvm_upkint( tid_array, 10, 1 );
pvm_upkint( problem_size, 1, 1 );
pvm_upkfloat( input_array, 100, 1 );
}
Fortran:
CALL PVMFTRECV( -1, 4, 60, 0, BUFID )
IF (BUFID .EQ. 0) GO TO 666
CALL PVMFUNPACK( INTEGER4, TIDS, 25, 1, INFO )
CALL PVMFUNPACK( REAL8, MATRIX, 100, 100, INFO )
666 CONTINUE
π ERRORS π
these error conditions can be returned by pvm_trecv:
PvmBadParamβ you gave an invalidtidvalue, ormsgtag < -1. bestie. read the parameter list again πPvmSysErrβpvmdnot responding. it's not ghosting you, it's genuinely down π
π§ SEE ALSO π§
pvm_bufinfo(3PVM), pvm_getminfo(3PVM), pvm_nrecv(3PVM), pvm_recv(3PVM), pvm_unpack(3PVM), pvm_probe(3PVM), pvm_send(3PVM), pvm_mcast(3PVM)
the whole friend group, go say hi π«Ά
and that's the page, babes π
this was TRECV(3PVM) from PVM Version 3.4, dated 8 February, 1994 β an absolute icon of a date, obsessed β go forth and receive with a timeout, and remember: wildcards are valid, -1 is your friend, and if you set both sec and usec to zero you're basically speedrunning. mwah π
π¦ where this page comes from
- debian bookworm: pvm-dev 3.4.6-5
- ubuntu jammy: pvm-dev 3.4.6-3.2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms