5
/* $Header: /tmp/hpctools/ga/tcgmsg/ipcv4.0/nxtsrv.c,v 1.4 1995-02-24 02:17:33 d3h325 Exp $ */
11
#define TYPE_NXTVAL 32767
15
This runs as highest no. process(es)
18
long cnt = 0; /* actual counter */
19
long lencnt = sizeof cnt; /* length of cnt */
20
long ndone = 0; /* no. finished for this loop */
21
long ntermin = 0; /* no. terminated so far (pend) */
22
long node = -1; /* select any node */
23
long type = TYPE_NXTVAL; /* message type */
24
long buf[2]; /* buffer to get values */
25
long lenbuf = sizeof buf; /* length of buffer */
26
long mproc; /* no. of processes running loop */
27
long nval; /* no. of values requested */
28
long done_list[16384]; /* list of processes finished with this loop */
29
long sync = 1; /* all info goes synchronously */
31
long lenmes, nodefrom;
39
/* Wait for input from any node */
41
RCV_(&type, (char *) buf, &lenbuf, &lenmes, &node, &nodefrom, &sync);
44
Error("NextValueServer: lenmes != lenbuf", lenmes);
50
(void) printf("NVS: from=%d, mproc=%d, ndone=%d, ntermin=%d\n",
51
nodefrom, mproc, ndone, ntermin);
55
/* Sending process is about to terminate. Send reply and disable
56
sending to him. If all processes have finished return. */
58
SND_(&type, (char *) &cnt, &lencnt, &nodefrom, &sync);
60
if (++ntermin == NNODES_())
65
/* This is what we are here for */
67
SND_(&type, (char *) &cnt, &lencnt, &nodefrom, &sync);
72
/* This process has finished the loop. Wait until all mproc
73
processes have finished before releasing it */
75
done_list[ndone++] = nodefrom;
77
if (ndone == -mproc) {
79
nodefrom = done_list[ndone];
80
SND_(&type, (char *) &cnt, &lencnt, &nodefrom, &sync);