CONTEXT(3PVM)

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

πŸ’– CONTEXT β€” the 3PVM era πŸ’–

okay bestie, sit down, hydrate, because we're talking about contexts in PVM Version 3.4 and honestly? it's giving main character energy. this is the page for pvm_newcontext, pvm_setcontext, pvm_freecontext, and pvm_getcontext β€” requesting a new context, changing context, freeing an existing context, and getting the current context, respectively. no cap. πŸŽ€


✨ NAME ✨

pvm_newcontext, pvm_setcontext, pvm_freecontext, pvm_getcontext β€” request new context, change context, free existing context, and get current context, respectively. πŸ¦‹


✨ SYNOPSIS ✨

C version, look at her:

C    int ctx = pvm_newcontext( void )
     int old_ctx = pvm_setcontext( int new_ctx )
     int info = pvm_freecontext( ctx )
     int ctx = pvm_getcontext( void )

Fortran version, equally iconic:

Fortran
     call pvmfnewcontext( ctx )
     call pvmfsetcontext( new_ctx, old_ctx )
     call pvmffreecontext( ctx, info )
     call pvmfgetcontext( ctx )

✨ PARAMETERS ✨

  • ctx β€” a context value. that's it, that's the girl. πŸ’…
  • new_ctx β€” the new context value, i.e. where you're headed. ✨
  • old_ctx β€” the prior context value, i.e. where you just were. πŸ•°οΈ
  • info β€” the result code, so you know how it went. πŸ‘‘

✨ DESCRIPTION ✨

the context functions hand you a system-wide unique context plus all the lil tools to manipulate it. lowkey obsessed.

contexts are the whole reason communicating tasks can automatically tell messages apart by the context they were sent in. so like: a message sent in context A by the sender must be received in context A by the recipient. a sender can send in any context it wants. but a recipient will not accept a message sent in a context that differs from its own. it's giving exclusive. πŸš«πŸ’Œ

one big use case is library routines. with contexts, a library routine's inter-communication can be logically separated from your application's inter-communication, which stops either of them from accidentally receiving the other's messages. no awkward cross-message situations. πŸ™ˆ

spawned tasks inherit the spawn-time context of their parent. and existing PVM applications? they work completely unchanged using the default context. slay.

now the four besties themselves:

  • pvm_newcontext returns a newly allocated context. > heads up bestie: this new context is not yet active. it exists, but it's not your current vibe yet. πŸ’€
  • pvm_setcontext changes the current context from old_ctx to new_ctx. glow up complete. ✨
  • pvm_freecontext frees ctx so that it may be reused. > fr fr: contexts are a system resource and they will be exhausted if you don't recycle them. don't do that to yourself. 😭
  • pvm_getcontext returns the current context of the requesting task. a lil mirror moment. πŸͺž

✨ EXAMPLES ✨

first up, the parent task with context β€” watch her work:

/* parent task with context */
     int cc, context0, context1;
     char buf[25];

     context0 = pvm_getcontext();       /*  get my current context */
     context1 = pvm_newcontext();       /*  get a new context */
     pvm_setcontext(context1);          /*  set my context to new context */
     printf("My context is: %d", context1);
     pvm_spawn("child", (char**)0, PvmTaskDefault, "", 1, &tid);
     cc = pvm_recv(-1, -1);             /*  receive message from child - in context1 */
     pvm_upkstr(buf);
     printf("%s", buf);
     pvm_setcontext(context0);          /*  reset my context to my original context0 */

and now the child task β€” because child inherits the parent's context as default, which is iconic of her:

/* child task with context - child inherits parent's context as default */
     int context;
     int ptid;
     char buf[25];

     ptid = pvm_parent();
     context = pvm_getcontext();        /*  get my current context */
     sprintf(buf, "Greetings from child who's context is: %d.", context);
     pvm_initsend(PvmDataDefault);
     pvm_pkstr(buf);
     pvm_send(ptid, 1);

the way that child just says hi with her context number printed in the message?? ate. πŸ’–


✨ ERRORS ✨

only system resource errors will be returned β€” because the context programs themselves literally do not generate errors. they're chill like that. 😌


✨ SEE ALSO ✨

ngl bestie, this section is empty in the original. no references listed. iykyk. 🫢


and that's the whole page, no crumbs left. this manual page is from PVM Version 3.4, dated 8 April, 1997 β€” yes, a vintage queen, and she still eats. πŸ’œ bye bestie, go recycle your contexts! 🧚🌈

πŸ“¦ where this page comes from