TRECV(3PVM)

πŸ“¦ version 3.4.6, in debian bookworm, ubuntu jammy

πŸ’– 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 (or sec and usec) β€” 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, then pvm_trecv will accept a message from any process which has a matching msgtag.
  • if msgtag = -1, then pvm_trecv will accept any message that is sent from process tid.
  • if tid and msgtag are both -1, then pvm_trecv will 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 invalid tid value, or msgtag < -1. not the vibe, fix ur inputs πŸ™ˆ
  • PvmSysErr β€” pvmd not 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