NRECV(3PVM)
π NRECV β the pvm_nrecv page (3PVM) π
okay bestie, so you're in the PVM section of the manual (that's the 3PVM part, in case anyone asks) and you wanna know if a message showed up yet, without, like, standing at the door forever waiting. Say less. PVM Version 3.4 has you. π¦
β¨ NAME β¨
pvm_nrecv β non-blocking receive. she checks, she does NOT wait around. main character energy only. π
β¨ SYNOPSIS β¨
C:
int bufid = pvm_nrecv( int tid, int msgtag )
Fortran:
call pvmfnrecv( tid, msgtag, bufid )
π PARAMETERS π
tidβ integer task identifier of the sending process, supplied by you, bestie. πmsgtagβ integer message tag supplied by you. and like,msgtagshould be>= 0. respectfully. πΈbufidβ integer that returns the value of the new active receive buffer identifier. values less than zero mean something went wrong. π
π DESCRIPTION π
pvm_nrecv peeks to see if a message with label msgtag has arrived from tid, and it also clears the current receive buffer if there is one. if a matching message has already arrived, pvm_nrecv immediately drops that message into a brand-new active receive buffer and hands you back the buffer identifier in bufid. iconic behavior. β¨
if the message you asked for hasn't arrived yet, pvm_nrecv returns immediately with a 0 in bufid. no waiting, no drama. and if some error happens, bufid will be < 0. π
a -1 in msgtag or tid matches anything. this is the wildcard, and it gives you these options:
- if
tid = -1andmsgtagis defined by you, thenpvm_nrecvwill accept a message from any process that has a matchingmsgtag. π«Ά - if
msgtag = -1andtidis defined by you, thenpvm_nrecvwill accept any message that is sent from processtid. π - if
tid = -1andmsgtag = -1, thenpvm_nrecvwill accept any message from any process. literally anything. wild. π
okay and now the part that's giving β¨guaranteedβ¨ β the PVM model promises this about message order: 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. and on top of that, if both messages arrive before task 2 does a receive, then a wildcard receive will always return message A. no cap. π₯
pvm_nrecv is non-blocking in the sense that the routine always returns immediately β either with the message, or with the info that the message hasn't arrived at the local pvmd yet. you can call pvm_nrecv multiple times to check if a given message has arrived yet. and also, the blocking receive pvm_recv can be called for the same message if your app runs out of work it could do before the data arrives. so like, you're never stuck. π
and if pvm_nrecv does return with the message, then the data in that message can be unpacked into your memory using the unpack routines. slay. π
πΈ EXAMPLES πΈ
C:
tid = pvm_parent();
msgtag = 4 ;
arrived = pvm_nrecv( tid, msgtag );
if ( arrived > 0)
info = pvm_upkint( tid_array, 10, 1 );
else
/* go do other computing */
Fortran:
CALL PVMFNRECV( -1, 4, ARRIVED )
IF ( ARRIVED .gt. 0 ) THEN
CALL PVMFUNPACK( INTEGER4, TIDS, 25, 1, INFO )
CALL PVMFUNPACK( REAL8, MATRIX, 100, 100, INFO )
ELSE
* GO DO USEFUL WORK
ENDIF
π ERRORS π
these error conditions can be returned by pvm_nrecv. take notes bestie:
PvmBadParamβ you gave an invalidtidvalue ormsgtag. πPvmSysErrβpvmdnot responding. she's ghosting you. π
π¦ SEE ALSO π¦
pvm_bufinfo(3PVM), pvm_getminfo(3PVM), pvm_recv(3PVM), pvm_unpack(3PVM), pvm_send(3PVM), pvm_mcast(3PVM)
k bye ily, go forth and receive non-blockingly π this whole thing is from PVM Version 3.4, dated 30 August, 1993 β yeah she's vintage, but vintage is just iconic with a timestamp. periodt. πβ¨
π¦ 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