1 %****************************************************************************
3 \section[Sysman.lc]{GUM Sysman Program}
5 % (c) The Parade/AQUA Projects, Glasgow University, 1994-1995.
6 % P. Trinder, November 30th. 1994.
8 %****************************************************************************
10 The Sysman task controls initiation, termination, global GC
11 synchronisation and statistics gathering. Based on K. Hammond's SysMan.lc
15 #define NON_POSIX_SOURCE /* so says Solaris */
22 static GLOBAL_TASK_ID gtids[MAX_PES], IOTask = 0, StatsTask = 0;
23 static long PEbuffer[MAX_PES];
28 static GLOBAL_TASK_ID sysman_id, sender_id;
32 static unsigned PEsTerminated = 0;
34 static rtsBool Finishing = rtsFalse;
38 #define checkerr(c) do {if((c)<0) { pvm_perror("Sysman"); EXIT(EXIT_FAILURE); }} while(0)
41 This Function not yet implemented for GUM
45 DoGlobalGC(STG_NO_ARGS)
49 HandleException(STG_NO_ARGS)
55 main(int argc, char **argv)
64 int spawn_flag = PvmTaskDefault;
72 if (*argv[1] == '-') {
73 spawn_flag = PvmTaskDebug;
77 sysman_id = pvm_mytid();/* This must be the first PVM call */
82 if ((petask = getenv(PETASK)) == NULL)
86 fprintf(stderr, "nPEs (%s) = %d\n", petask, nPEs);
89 /* Check that we can create the number of PE and IMU tasks requested */
91 fprintf(stderr, "No more than %d PEs allowed (%d requested)\n", MAX_PES, nPEs);
94 /* Create the PE Tasks */
96 /* Initialise the PE task arguments from Sysman's arguments */
99 fprintf(stderr, "Spawning %d PEs(%s) ...\n", nPEs, petask);
100 fprintf(stderr, " args: ");
101 for (i = 0; pargv[i]; ++i)
102 fprintf(stderr, "%s, ", pargv[i]);
103 fprintf(stderr, "\n");
106 checkerr(pvm_spawn(petask, pargv, spawn_flag, "", nPEs, gtids));
107 for (i = 0; i < nPEs; i++)
108 PEbuffer[i] = (long) gtids[i];
110 fprintf(stderr, "Spawned /* PWT */\n");
115 SysMan joins PECTLGROUP, so that it can wait (at the
116 barrier sysnchronisation a few instructions later) for the
117 other PE-tasks to start.
119 Other comments on PVM groupery:
121 The manager group (MGRGROUP) is vestigial at the moment. It
122 may eventually include a statistics manager, garbage
125 I suspect that you're [Kei Davis] right: Sysman shouldn't
126 be in PEGROUP, it's a hangover from GRIP.
128 (Phil Trinder, 95/10)
130 checkerr(pvm_joingroup(PECTLGROUP));
132 fprintf(stderr, "Joined PECTLGROUP /* PWT */\n");
135 /* Wait for all the PEs and IMUs to arrive */
136 checkerr(pvm_barrier(PECTLGROUP, nPEs + 1));
139 fprintf(stderr, "PECTLGROUP barrier passed /* HWL */\n");
142 /* Broadcast Global Task Ids of all PEs */
144 pvm_initsend(PvmDataDefault);
145 PutArgs(PEbuffer, nPEs);
146 pvm_bcast(PEGROUP, PP_PETIDS);
149 /* Find an IO task */
150 for (i = 0; IOTask <= 0 || status != PvmOk; ++i) {
151 IOTask = pvm_gettid(PEGROUP, i);
152 status = pvm_pstat(IOTask);
153 fprintf(stderr, "Task %x, Status %x\n", IOTask, status);
159 fprintf(stderr, "IO Task is [t%x]\n", IOTask);
162 pvm_initsend(PvmDataDefault);
163 pvm_send(IOTask, PP_IO_INIT);
165 pvm_initsend(PvmDataDefault);
166 pvm_bcast(PEGROUP, PP_INIT);
168 fprintf(stderr, "Broadcast PP_INIT to all PEs\n");
173 fprintf(stderr, "Sysman successfully initialized!\n");
176 /* Process incoming messages */
178 if ((rbufid = pvm_recv(ANY_TASK, ANY_OPCODE)) < 0)
179 pvm_perror("Sysman: Receiving Message");
182 pvm_bufinfo(rbufid, &nbytes, &opcode, &sender_id);
185 fprintf(stderr, "HWL-DBG(SysMan; main loop): rbufid=%x, nbytes = %d, opcode = %x, sender_id = %x\n",
186 rbufid, nbytes, opcode, sender_id);
191 /* This Function not yet implemented for GUM */
192 fprintf(stderr, "Global GC from %x Not yet implemented for GUM!\n", sender_id);
193 sync(PECTLGROUP, PP_FULL_SYSTEM);
194 broadcast(PEGROUP, PP_GC_INIT);
196 broadcast(PEGROUP, PP_INIT);
201 /* This Function not yet implemented for GUM */
205 fprintf(stderr, "Finish from %x\n", sender_id);
207 long buf = (long) StatsTask;
209 pvm_initsend(PvmDataDefault);
210 pvm_pklong(&buf, 1, 1);
211 pvm_bcast(PEGROUP, PP_FINISH);
216 if (PEsTerminated >= nPEs) {
217 broadcast(PEGROUP, PP_FINISH);
218 broadcast(MGRGROUP, PP_FINISH);
219 pvm_lvgroup(PEGROUP);
220 pvm_lvgroup(PECTLGROUP);
221 pvm_lvgroup(MGRGROUP);
228 fprintf(stderr, "Fail from %x\n", sender_id);
231 broadcast(PEGROUP, PP_FAIL);
237 /* char *opname = GetOpName(opcode);
238 fprintf(stderr,"Sysman: Unrecognised opcode %s (%x)\n",
240 fprintf(stderr, "Sysman: Unrecognised opcode (%x)\n",
252 @myexit@ for the system manager.