TRECV(3PVM)
π TRECV(3PVM) π
okay bestie, so this is pvm_trecv from PVM Version 3.4 β it's the "receive but make it β¨timedβ¨" routine, and honestly? it ate. let's get into it π«Ά
β¨ NAME β¨
pvm_trecv β receive with timeout, aka "wait for a message but not, like, forever" π
πΈ SYNOPSIS πΈ
C
#include <sys/time.h>
int bufid = pvm_trecv( int tid, int msgtag, struct timeval *tmout )
Fortran
call pvmftrecv( tid, msgtag, sec, usec, bufid )
π PARAMETERS π
tidβ an Integer that matches the task identifier of the sending process. iykyk, it's who you're waiting on πmsgtagβ an Integer matching the message tag. should be>= 0, no cap.tmout(orsecandusec) β how long you're willing to wait before just giving up and returning without a message. the patience meter β³bufidβ an Integer that returns the value of the new active receive buffer identifier. values less than zero mean something went wrong, so like, error core π
π¦ DESCRIPTION π¦
so pvm_trecv blocks the process until a message with label msgtag has arrived from tid. then it places that message in a new active receive buffer, and also clears the current receive buffer. main character behaviour, honestly. but here's the twist: if no matching message arrives within the specified waiting time, pvm_trecv just returns without a message. no drama, no ghosting, it's just done. π
a -1 in msgtag or tid matches anything. this gives you these options, bestie:
- 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. wildcard queen π
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. with both set to zero, pvm_trecv behaves the same as pvm_nrecv, which is to probe for messages and return immediately even if none are matched β like a vibe check but for messages π. 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. so like, zero patience or infinite patience, your call π«Ά
the PVM model guarantees the following about message order, and this is not a drill:
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. moreover, if both messages arrive before task 2 does a receive, then a wildcard receive will always return message A. periodt. the order is sacred β¨
if pvm_trecv is successful, bufid will be the new active receive buffer identifier. if no message is received, pvm_trecv returns 0. if some error occurs then bufid will be < 0. three moods, honestly π
once pvm_trecv returns, the data in the message can be unpacked into the user's memory using the unpack routines. that's the whole point, 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, and yes we're naming names:
PvmBadParamβ giving an invalidtidvalue, ormsgtag < -1. not the vibe, fix ur inputs πPvmSysErrβpvmdnot responding. it's giving silence. it's giving ghosted. scream. π
π₯ 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) β go read those too, the whole friend group is iconic π
k byeeee, this was PVM Version 3.4, dated 8 February, 1994 β yeah bestie she's an old queen but she still slays πβ¨π
π¦ 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