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)
66 int spawn_flag = PvmTaskDefault;
74 if (*argv[1] == '-') {
75 spawn_flag = PvmTaskDebug;
79 sysman_id = pvm_mytid();/* This must be the first PVM call */
84 if ((petask = getenv(PETASK)) == NULL)
88 fprintf(stderr, "nPEs (%s) = %d\n", petask, nPEs);
91 /* Check that we can create the number of PE and IMU tasks requested */
93 fprintf(stderr, "No more than %d PEs allowed (%d requested)\n", MAX_PES, nPEs);
96 /* Create the PE Tasks */
98 /* Initialise the PE task arguments from Sysman's arguments */
101 fprintf(stderr, "Spawning %d PEs(%s) ...\n", nPEs, petask);
102 fprintf(stderr, " args: ");
103 for (i = 0; pargv[i]; ++i)
104 fprintf(stderr, "%s, ", pargv[i]);
105 fprintf(stderr, "\n");
108 checkerr(pvm_spawn(petask, pargv, spawn_flag, "", nPEs, gtids));
109 for (i = 0; i < nPEs; i++)
110 PEbuffer[i] = (long) gtids[i];
112 fprintf(stderr, "Spawned /* PWT */\n");
116 /* Join the PE sysman groups in order to allow barrier synchronisation */
117 checkerr(pvm_joingroup(PECTLGROUP));
119 fprintf(stderr, "Joined PECTLGROUP /* PWT */\n");
122 /* Wait for all the PEs and IMUs to arrive */
123 checkerr(pvm_barrier(PECTLGROUP, nPEs + 1));
126 fprintf(stderr, "PECTLGROUP barrier passed /* HWL */\n");
129 /* Broadcast Global Task Ids of all PEs */
131 pvm_initsend(PvmDataDefault);
132 PutArgs(PEbuffer, nPEs);
133 pvm_bcast(PEGROUP, PP_PETIDS);
136 /* Find an IO task */
137 for (i = 0; IOTask <= 0 || status != PvmOk; ++i) {
138 IOTask = pvm_gettid(PEGROUP, i);
139 status = pvm_pstat(IOTask);
140 fprintf(stderr, "Task %x, Status %x\n", IOTask, status);
146 fprintf(stderr, "IO Task is [t%x]\n", IOTask);
149 pvm_initsend(PvmDataDefault);
150 pvm_send(IOTask, PP_IO_INIT);
152 pvm_initsend(PvmDataDefault);
153 pvm_bcast(PEGROUP, PP_INIT);
155 fprintf(stderr, "Broadcast PP_INIT to all PEs\n");
160 fprintf(stderr, "Sysman successfully initialized!\n");
163 /* Process incoming messages */
165 if ((rbufid = pvm_recv(ANY_TASK, ANY_OPCODE)) < 0)
166 pvm_perror("Sysman: Receiving Message");
169 pvm_bufinfo(rbufid, &nbytes, &opcode, &sender_id);
172 fprintf(stderr, "HWL-DBG(SysMan; main loop): rbufid=%x, nbytes = %d, opcode = %x, sender_id = %x\n",
173 rbufid, nbytes, opcode, sender_id);
178 /* This Function not yet implemented for GUM */
179 fprintf(stderr, "Global GC from %x Not yet implemented for GUM!\n", sender_id);
180 sync(PECTLGROUP, PP_FULL_SYSTEM);
181 broadcast(PEGROUP, PP_GC_INIT);
183 broadcast(PEGROUP, PP_INIT);
188 /* This Function not yet implemented for GUM */
192 fprintf(stderr, "Finish from %x\n", sender_id);
194 long buf = (long) StatsTask;
196 pvm_initsend(PvmDataDefault);
197 pvm_pklong(&buf, 1, 1);
198 pvm_bcast(PEGROUP, PP_FINISH);
203 if (PEsTerminated >= nPEs) {
204 broadcast(PEGROUP, PP_FINISH);
205 broadcast(MGRGROUP, PP_FINISH);
206 pvm_lvgroup(PEGROUP);
207 pvm_lvgroup(PECTLGROUP);
208 pvm_lvgroup(MGRGROUP);
215 fprintf(stderr, "Fail from %x\n", sender_id);
218 broadcast(PEGROUP, PP_FAIL);
224 /* char *opname = GetOpName(opcode);
225 fprintf(stderr,"Sysman: Unrecognised opcode %s (%x)\n",
227 fprintf(stderr, "Sysman: Unrecognised opcode (%x)\n",
238 @myexit@ for the system manager.