| | 1083 | | tm_spawn(tp, mp) | | | 1084 | | struct task *tp; | | | 1085 | | struct pmsg *mp; | | | 1086 | | { | | | 1087 | | char *where = 0; | | | 1088 | | struct waitc *wp; | | | 1089 | | struct waitc_spawn *wxp = 0; | | | 1090 | | struct htab *htp; | | | 1091 | | struct hostd *hp; | | | 1092 | | int hh; | | | 1093 | | int i; | | | 1094 | | char *wd = 0; | | | 1095 | | char *wdenv = 0; | | | 1096 | | char *ptr; | | | 1097 | | int sz; | | | 1098 | | | | | 1099 | | | | | 1100 | | | | | 1101 | | | | | 1102 | | | | | 1103 | | wxp = TALLOC(1, struct waitc_spawn, "waix");
| | | 1104 | | BZERO((char*)wxp, sizeof(struct waitc_spawn));
| | | 1105 | | | | | 1106 | | if (upkstralloc(mp, &wxp->w_file) | | | 1107 | | || upkint(mp, &wxp->w_flags) | | | 1108 | | || upkstralloc(mp, &where) | | | 1109 | | || upkint(mp, &wxp->w_veclen) | | | 1110 | | || upkint(mp, &wxp->w_argc)) | | | 1111 | | goto bad; | | | 1112 | | | | | 1113 | | if (wxp->w_veclen < 1) | | | 1114 | | goto bad; | | | 1115 | | | | | 1116 | | wxp->w_argv = TALLOC(wxp->w_argc + 1, char*, "argv");
| | | 1117 | | BZERO((char*)wxp->w_argv, (wxp->w_argc + 1) * sizeof(char*));
| | | 1118 | | for (i = 0; i < wxp->w_argc; i++) | | | 1119 | | if (upkstralloc(mp, &wxp->w_argv[i])) | | | 1120 | | goto bad; | | | 1121 | | | | | 1122 | | if (upkuint(mp, &wxp->w_outtid) | | | 1123 | | || upkuint(mp, &wxp->w_outctx) | | | 1124 | | || upkuint(mp, &wxp->w_outtag) | | | 1125 | | || upkuint(mp, &wxp->w_trctid) | | | 1126 | | || upkuint(mp, &wxp->w_trcctx) | | | 1127 | | || upkuint(mp, &wxp->w_trctag)) | | | 1128 | | goto bad; | | | 1129 | | | | | 1130 | | | | | 1131 | | | | | 1132 | | | | | 1133 | | | | | 1134 | | ptr = where; | | | 1135 | | while ( *ptr != ':' && *ptr != '\0' ) | | | 1136 | | ptr++; | | | 1137 | | if ( *ptr == ':' ) { | | | 1138 | | *ptr++ = '\0'; | | | 1139 | | wd = ptr; | | | 1140 | | } | | | 1141 | | | | | 1142 | | | | | 1143 | | | | | 1144 | | | | | 1145 | | | | | 1146 | | if (upkuint(mp, &wxp->w_nenv)) | | | 1147 | | goto bad; | | | 1148 | | sz = wxp->w_nenv + 1 + (wd ? 1 : 0); | | | 1149 | | wxp->w_env = TALLOC(sz, char*, "env");
| | | 1150 | | BZERO((char*)wxp->w_env, sz * sizeof(char*));
| | | 1151 | | for (i = 0; i < wxp->w_nenv; i++) | | | 1152 | | if (upkstralloc(mp, &wxp->w_env[i])) | | | 1153 | | goto bad; | | | 1154 | | | | | 1155 | | | | | 1156 | | | | | 1157 | | | | | 1158 | | | | | 1159 | | if ( wd ) { | | | 1160 | | sz = strlen(wd) + strlen("PVMSPAWNWD=") + 1; | | | 1161 | | wdenv = TALLOC(sz, char, "wdenv");
| | | 1162 | | sprintf( wdenv, "PVMSPAWNWD=%s", wd ); | | | 1163 | | wxp->w_env[ (wxp->w_nenv)++ ] = STRALLOC( wdenv );
| | | 1164 | | } | | | 1165 | | | | | 1166 | | | | | 1167 | | | | | 1168 | | | | | 1169 | | | | | 1170 | | if ((wxp->w_flags & (PvmTaskHost|PvmTaskArch)) && !where)
| | | 1171 | | goto bad; | | | 1172 | | | | | 1173 | | htp = ht_new(1); | | | 1174 | | | | | 1175 | | if (wxp->w_flags & PvmTaskHost) {
| | | 1176 | | if (hp = nametohost(hosts, where)) | | | 1177 | | ht_insert(htp, hp); | | | 1178 | | | | | 1179 | | } else { | | | 1180 | | if (wxp->w_flags & PvmTaskArch) {
| | | 1181 | | for (hh = hosts->ht_last; hh > 0; hh--) | | | 1182 | | if ((hp = hosts->ht_hosts[hh]) | | | 1183 | | && !strcmp(where, hp->hd_arch)) | | | 1184 | | ht_insert(htp, hp); | | | 1185 | | | | | 1186 | | #ifdef IMA_BEOLIN | | | | | ... | | | 1188 | | } else if (wxp->w_flags & PvmMppFront) { | | | 1189 | | hp = hosts->ht_hosts[hosts->ht_local]; | | | 1190 | | ht_insert(htp, hp); | | | 1191 | | #endif | | | 1192 | | | | | 1193 | | } else { | | | 1194 | | ht_merge(htp, hosts); | | | 1195 | | } | | | 1196 | | } | | | 1197 | | | | | 1198 | | if (wxp->w_flags & PvmHostCompl) {
| | | 1199 | | for (hh = hosts->ht_last; hh > 0; hh--) { | | | 1200 | | if (hh <= htp->ht_last && (hp = htp->ht_hosts[hh])) | | | 1201 | | ht_delete(htp, hp); | | | 1202 | | else | | | 1203 | | if (hp = hosts->ht_hosts[hh]) | | | 1204 | | ht_insert(htp, hp); | | | 1205 | | } | | | 1206 | | } | | | 1207 | | | | | 1208 | | if (pvmdebmask & PDMTASK) {
| | | 1209 | | pvmlogerror("tm_spawn() host set:\n"); | | | 1210 | | ht_dump(htp); | | | 1211 | | } | | | 1212 | | | | | 1213 | | if ( !(wxp->w_flags & PvmNoSpawnParent) ) {
| | | 1214 | | wxp->w_ptid = tp->t_tid; | | | 1215 | | } | | | 1216 | | else | | | 1217 | | wxp->w_ptid = PvmParentNotSet;
| | | 1218 | | | | | 1219 | | | | | 1220 | | | | | 1221 | | | | | 1222 | | | | | 1223 | | wxp->w_ht = htp; | | | 1224 | | wxp->w_vec = TALLOC(wxp->w_veclen, int, "vec");
| | | 1225 | | BZERO((char*)wxp->w_vec, wxp->w_veclen * sizeof(int));
| | | 1226 | | wxp->w_togo = wxp->w_veclen; | | | 1227 | | |
| | 1263 | | | | assign_tasks(wp) | | | 1264 | | | | struct waitc *wp; | | | 1265 | | | | { | | | 1266 | | | | static int lasthh = -1; | | | 1267 | | | | | | | 1268 | | | | struct waitc_spawn *wxp = (struct waitc_spawn*)wp->wa_spec; | | | 1269 | | | | struct htab *htp; | | | 1270 | | | | int *vec; | | | 1271 | | | | int veclen; | | | 1272 | | | | int count = 0; | | | 1273 | | | | int nh; | | | 1274 | | | | int a = 0; | | | 1275 | | | | int na = 0; | | | 1276 | | | | struct waitc *wp2; | | | 1277 | | | | struct hostd *hp; | | | 1278 | | | | struct pmsg *mp; | | | 1279 | | | | int t; | | | 1280 | | | | int i; | | | 1281 | | | | int tid; | | | 1282 | | | | struct timeval now; | | | 1283 | | | | | | | 1284 | | | | if (!wxp) | | | 1285 | | | | return 0; | | | 1286 | | | | | | | 1287 | | | | htp = wxp->w_ht; | | | 1288 | | | | vec = wxp->w_vec; | | | 1289 | | | | veclen = wxp->w_veclen; | | | 1290 | | | | | | | 1291 | | | | | | | 1292 | | | | | | | 1293 | | | | | | | 1294 | | | | | | | 1295 | | | | if (!htp->ht_cnt) | | | 1296 | | | | for (t = veclen; t-- > 0; ) | | | 1297 | | | | if (!vec[t]) | | | 1298 | | | | vec[t] = PvmNoHost;
| | | 1299 | | | | | | | 1300 | | | | | | | 1301 | | | | | | | 1302 | | | | | | | 1303 | | | | | | | 1304 | | | | for (t = veclen; t-- > 0; ) | | | 1305 | | | | if (!vec[t]) | | | 1306 | | | | count++; | | | 1307 | | | | | | | 1308 | | | | if (!count) { | | | 1309 | | | | pkint(wp->wa_mesg, wxp->w_veclen); | | | 1310 | | | | for (t = 0; t < wxp->w_veclen; t++) { | | | 1311 | | | | tid = wxp->w_vec[t]; | | | 1312 | | | | pkint(wp->wa_mesg, tid); | | | 1313 | | | | if (TIDISTASK(tid) && wxp->w_trctid > 0) {
| | | 1314 | | | | tev_send_spntask( | | | 1315 | | | | wxp->w_trctid, wxp->w_trcctx, wxp->w_trctag, | | | 1316 | | | | tid, wxp->w_ptid ); | | | 1317 | | | | } | | | 1318 | | | | if (TIDISTASK(tid) && wxp->w_outtid > 0) {
| | | | | | | ... | | | 1331 | | | | | | | 1332 | | | | free_wait_spawn(wxp); | | | 1333 | | | | wp->wa_spec = 0; | | | 1334 | | | | return 0; | | | 1335 | | | | } | | | 1336 | | | | | | | 1337 | | | | | | | 1338 | | | | | | | 1339 | | | | | | | 1340 | | | | | | | 1341 | | | | nh = min(htp->ht_cnt, count);
| | | 1342 | | | | | | | 1343 | | | | | | | 1344 | | | | | | | 1345 | | | | if (lasthh == -1) | | | 1346 | | | | lasthh = hosts->ht_local + 1; | | | 1347 | | | | if (lasthh > htp->ht_last) | | | 1348 | | | | lasthh = 0; | | | 1349 | | | | while (!htp->ht_hosts[lasthh]) | | | 1350 | | | | if (++lasthh > htp->ht_last) | | | 1351 | | | | lasthh = 1; | | | 1352 | | | | hp = htp->ht_hosts[lasthh]; | | | 1353 | | | | | | | 1354 | | | | for (t = 0; t < veclen && vec[t]; t++); | | | 1355 | | | | | | | 1356 | | | | while (t < veclen) { | | | 1357 | | | | | | | 1358 | | | | | | | 1359 | | | | | | | 1360 | | | | | | | 1361 | | | | vec[t] = hp->hd_hostpart; | | | 1362 | | | | na++; | | | 1363 | | | | | | | 1364 | | | | | | | 1365 | | | | | | | 1366 | | | | if ((a += nh) >= count) { | | | 1367 | | | | a -= count; | | | 1368 | | | | | | | 1369 | | | | wp2 = wait_new(WT_SPAWN);
| | | 1370 | | | | wp2->wa_tid = wp->wa_tid; | | | 1371 | | | | wp2->wa_on = hp->hd_hostpart; | | | 1372 | | | | wp2->wa_spec = wp->wa_spec; | | wp->wa_mesg <= 4095 | 1373 | | | | wp->wa_mesg->m_ref++; | | | 1374 | | | | wp2->wa_mesg = wp->wa_mesg; | | | 1375 | | | | LISTPUTBEFORE(wp, wp2, wa_peer, wa_rpeer);
| | | 1376 | | | | | | | 1377 | | | | mp = mesg_new(0); | | | 1378 | | | | pkint(mp, wxp->w_ptid); | | | 1379 | | | | pkstr(mp, wxp->w_file); | | | 1380 | | | | pkint(mp, wxp->w_flags); | | | 1381 | | | | pkint(mp, na); | | | 1382 | | | | pkint(mp, wxp->w_argc); | | | 1383 | | | | for (i = 0; i < wxp->w_argc; i++) | | | 1384 | | | | pkstr(mp, wxp->w_argv[i]); | | | 1385 | | | | pkint(mp, wxp->w_outtid); | | | 1386 | | | | pkint(mp, wxp->w_outctx); | | | 1387 | | | | pkint(mp, wxp->w_outtag); | | | 1388 | | | | pkint(mp, wxp->w_trctid); | | | 1389 | | | | pkint(mp, wxp->w_trcctx); | | | 1390 | | | | pkint(mp, wxp->w_trctag); | | | 1391 | | | | pkint(mp, wxp->w_nenv); | | | 1392 | | | | for (i = 0; i < wxp->w_nenv; i++) | | | 1393 | | | | pkstr(mp, wxp->w_env[i]); | | | 1394 | | | | pkint(mp, (t+1)-na); | | | 1395 | | | | pkint(mp, count); | | | 1396 | | | | mp->m_dst = hp->hd_hostpart | TIDPVMD;
| | | 1397 | | | | mp->m_tag = DM_EXEC;
| | | 1398 | | | | mp->m_wid = wp2->wa_wid; | | | 1399 | | | | | | | 1400 | | | | do { | | | 1401 | | | | if (++lasthh > htp->ht_last) | | | 1402 | | | | lasthh = 1; | | | 1403 | | | | } while (!htp->ht_hosts[lasthh]); | | | 1404 | | | | | | | 1405 | | | | sendmessage(mp); | | | 1406 | | | | | | | 1407 | | | | hp = htp->ht_hosts[lasthh]; | | | 1408 | | | | na = 0; | | | 1409 | | | | } | | | 1410 | | | | for (t++ ; t < veclen && vec[t]; t++); |
|