1CONTEXT(3PVM)                   PVM Version 3.4                  CONTEXT(3PVM)
2
3
4

NAME

6       pvm_newcontext - Request new context.
7       pvm_setcontext - Change context.
8       pvm_freecontext - Free existing context.
9       pvm_getcontext - Get current context.
10
11

SYNOPSIS

13       C    int ctx = pvm_newcontext( void )
14            int old_ctx = pvm_setcontext( int new_ctx )
15            int info = pvm_freecontext( ctx )
16            int ctx = pvm_getcontext( void )
17
18       Fortran
19            call pvmfnewcontext( ctx )
20            call pvmfsetcontext( new_ctx, old_ctx )
21            call pvmffreecontext( ctx, info )
22            call pvmfgetcontext( ctx )
23
24

PARAMETERS

26       ctx
27              Context value.
28
29       new_ctx
30              New context value.
31
32       old_ctx
33              Prior context value.
34
35       info
36              Result code.
37
38

DESCRIPTION

40       The  context  functions  provide  a  system-wide unique context and the
41       means to manipulate this context.
42
43       Contexts provide the ability for communicating tasks  to  automatically
44       differentiate  messages by the context in which they were sent.  Thus a
45       message sent in context A by the sender must be received in  context  A
46       by the recipient.  A sender may send in any context.  However, a recip‐
47       ient will not accept a message sent in a context that differs from  its
48       own.
49
50       One  such  use  of  contexts is with library routines.  Using contexts,
51       library routine inter-communication may be logically seperated from the
52       user's  application inter-communication. This will prevent the inadver‐
53       tent receipt of one another's messages.
54
55       Spawned tasks inherit the spawn-time context of their parent.  Existing
56       PVM applications work unchanged using the default context.
57
58       pvm_newcontext  returns  a  newly allocated context.  However, this new
59       context is not yet active.
60
61       pvm_setcontext changes the current context from old_ctx to new_ctx.
62
63       pvm_freecontext frees ctx so that it may be  reused.   Contexts  are  a
64       system resource that will be exhausted if not recycled.
65
66       pvm_getcontext returns the current context of the requesting task.
67
68
69

EXAMPLES

71       /* parent task with context */
72            int cc, context0, context1;
73            char buf[25];
74
75            context0 = pvm_getcontext();       /*  get my current context */
76            context1 = pvm_newcontext();       /*  get a new context */
77            pvm_setcontext(context1);          /*  set my context to new context */
78            printf("My context is: %d", context1);
79            pvm_spawn("child", (char**)0, PvmTaskDefault, "", 1, &tid);
80            cc = pvm_recv(-1, -1);             /*  receive message from child - in context1 */
81            pvm_upkstr(buf);
82            printf("%s", buf);
83            pvm_setcontext(context0);          /*  reset my context to my original context0 */
84
85
86
87       /* child task with context - child inherits parent's context as default */
88            int context;
89            int ptid;
90            char buf[25];
91
92            ptid = pvm_parent();
93            context = pvm_getcontext();        /*  get my current context */
94            sprintf(buf, "Greetings from child who's context is: %d.", context);
95            pvm_initsend(PvmDataDefault);
96            pvm_pkstr(buf);
97            pvm_send(ptid, 1);
98
99
100
101

ERRORS

103       Only  system  resource  errors will be returned as the context programs
104       themselves do not generate errors.
105

SEE ALSO

107                                 8 April, 1997                   CONTEXT(3PVM)
Impressum