Changeset 7a81686 in git


Ignore:
Timestamp:
Mar 8, 2011, 3:35:04 PM (13 years ago)
Author:
Andreas Steenpaß <steenpas@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
cf29d0c4a67afdf6039daded7f0bcbd17622873a
Parents:
8a9bcca97de899994799612c3fb8014a6b008467
Message:
waitfirst and waitall adjusted

git-svn-id: file:///usr/local/Singular/svn/trunk@13945 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Singular/iparith.cc

    r8a9bcca r7a81686  
    31983198static BOOLEAN jjWAIT1ST2(leftv res, leftv u, leftv v)
    31993199{
     3200// input: u: a list with links of type
     3201//           ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
     3202//        v: timeout for select in seconds
     3203//           or 0 for polling
     3204// returns: ERROR (via Werror): timeout negative
     3205//           0: timeout (or polling): none ready
     3206//           i>0: (at least) L[i] is ready
    32003207  lists Lforks = (lists)u->Data();
    32013208  int t = (int)(long)v->Data();
     3209  if(t < 0)
     3210  {
     3211    WerrorS("negative timeout"); return TRUE;
     3212  }
    32023213  int i = slStatusSsiL(Lforks, t*1000);
    3203   if ( i < 0 ) i = 0;
    32043214  res->data = (void*)(long)i;
    32053215  return FALSE;
     
    32073217static BOOLEAN jjWAITALL2(leftv res, leftv u, leftv v)
    32083218{
    3209 /* returns 1 iff all forks are finished; 0 otherwise */
    3210   lists Lforks = (lists)u->Data();
     3219// input: u: a list with links of type
     3220//           ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
     3221//        v: timeout for select in seconds
     3222//           or 0 for polling
     3223// returns: ERROR (via Werror): timeout negative
     3224//           0: timeout (or polling): none ready
     3225//           1: all links are ready
     3226  lists Lforks = (lists)u->CopyD();
    32113227  int timeout = 1000*(int)(long)v->Data();
    3212   lists oneFork=(lists)omAllocBin(slists_bin);
    3213   oneFork->Init(1);
     3228  if(timeout < 0)
     3229  {
     3230    WerrorS("negative timeout"); return TRUE;
     3231  }
     3232  int t = getRTimer()/timer_resolution;
    32143233  int i;
    3215   int t = getTimer();
    32163234  int ret = 1;
    3217   for (int j = 0; j <= Lforks->nr; j++)
    3218   {
    3219     oneFork->m[0].Copy(&Lforks->m[j]);
    3220     i = slStatusSsiL(oneFork, timeout);
    3221     if (i == 1)
    3222     {
    3223       timeout = timeout - getTimer() + t;
    3224     }
    3225     else { ret = 0; j = Lforks->nr+1; /* terminate the for loop */ }
    3226     omFreeSize((ADDRESS)oneFork->m,sizeof(sleftv));
    3227   }
    3228   omFreeBin((ADDRESS)oneFork, slists_bin);
     3235  for(int nfinished = 0; nfinished < Lforks->nr; nfinished++)
     3236  {
     3237    i = slStatusSsiL(Lforks, timeout);
     3238    if(i > 0)
     3239    {
     3240      Lforks->m[i-1].CleanUp();
     3241      Lforks->m[i-1].rtyp=DEF_CMD;
     3242      Lforks->m[i-1].data=NULL;
     3243      timeout = si_max(0,timeout - getRTimer()/timer_resolution + t);
     3244    }
     3245    else { ret = 0; break; /* terminate the for loop */ }
     3246  }
     3247  Lforks->Clean();
    32293248  res->data = (void*)(long)ret;
    32303249  return FALSE;
     
    45974616BOOLEAN jjWAIT1ST1(leftv res, leftv a)
    45984617{
     4618// input: a: a list with links of type
     4619//           ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
     4620// returns: i>0: (at least) a[i] is ready
    45994621  lists Lforks = (lists)a->Data();
    46004622  int i = slStatusSsiL(Lforks, -1);
    4601   while (i <= 0) i = slStatusSsiL(Lforks, 10000000); /* redo this all 10 seconds */
    46024623  res->data = (void*)(long)i;
    46034624  return FALSE;
     
    46054626BOOLEAN jjWAITALL1(leftv res, leftv a)
    46064627{
    4607   lists Lforks = (lists)a->Data();
    4608   lists oneFork=(lists)omAllocBin(slists_bin);
    4609   oneFork->Init(1);
     4628// input: a: a list with links of type
     4629//           ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
     4630// returns: nothing. All links are ready when finished.
     4631  lists Lforks = (lists)u->CopyD();
    46104632  int i;
    4611   for (int j = 0; j <= Lforks->nr; j++)
    4612   {
    4613     oneFork->m[0].Copy(&Lforks->m[j]);
    4614     i = slStatusSsiL(oneFork, -1);
    4615     while (i != 1) i = slStatusSsiL(oneFork, 10000000); /* redo this all 10 seconds */
    4616     omFreeSize((ADDRESS)oneFork->m,sizeof(sleftv));
    4617   }
    4618   omFreeBin((ADDRESS)oneFork, slists_bin);
     4633  for(int nfinished = 0; nfinished < Lforks->nr; nfinished++)
     4634  {
     4635    i = slStatusSsiL(Lforks, -1);
     4636    Lforks->m[i-1].CleanUp();
     4637    Lforks->m[i-1].rtyp=DEF_CMD;
     4638    Lforks->m[i-1].data=NULL;
     4639  }
     4640  Lforks->Clean();
    46194641  return FALSE;
    46204642}
  • Singular/ssiLink.cc

    r8a9bcca r7a81686  
    12181218  for(i=L->nr; i>=0; i--)
    12191219  {
    1220     if (L->m[i].Typ()!=LINK_CMD)
    1221     { WerrorS("all elements must be of type link"); return -2;}
    1222     l=(si_link)L->m[i].Data();
    1223     if(SI_LINK_OPEN_P(l)==0)
    1224     { WerrorS("all links must be open"); return -2;}
    1225     if (((strcmp(l->m->type,"ssi")!=0) && (strcmp(l->m->type,"MPtcp")!=0))
    1226     || ((strcmp(l->mode,"fork")!=0) && (strcmp(l->mode,"tcp")!=0)
    1227        && (strcmp(l->mode,"launch")!=0)))
    1228     {
    1229       WerrorS("all links must be of type ssi:fork, ssi:tcp, MPtcp:fork or MPtcp:launch");
    1230       return -2;
    1231     }
     1220    if (L->m[i].Typ()!=DEF_CMD)
     1221    {
     1222      if (L->m[i].Typ()!=LINK_CMD)
     1223      { WerrorS("all elements must be of type link"); return -2;}
     1224      l=(si_link)L->m[i].Data();
     1225      if(SI_LINK_OPEN_P(l)==0)
     1226      { WerrorS("all links must be open"); return -2;}
     1227      if (((strcmp(l->m->type,"ssi")!=0) && (strcmp(l->m->type,"MPtcp")!=0))
     1228      || ((strcmp(l->mode,"fork")!=0) && (strcmp(l->mode,"tcp")!=0)
     1229        && (strcmp(l->mode,"launch")!=0)))
     1230      {
     1231        WerrorS("all links must be of type ssi:fork, ssi:tcp, MPtcp:fork or MPtcp:launch");
     1232        return -2;
     1233      }
    12321234    #ifdef HAVE_MPSR
    1233     if (strcmp(l->m->type,"ssi")==0)
    1234     {
     1235      if (strcmp(l->m->type,"ssi")==0)
     1236      {
     1237        d=(ssiInfo*)l->data;
     1238        d_fd=d->fd_read;
     1239      }
     1240      else
     1241      {
     1242        dd=(MP_Link_pt)l->data;
     1243        d_fd=((MP_TCP_t *)dd->transp.private1)->sock;
     1244      }
     1245    #else
    12351246      d=(ssiInfo*)l->data;
    12361247      d_fd=d->fd_read;
    1237     }
    1238     else
    1239     {
    1240       dd=(MP_Link_pt)l->data;
    1241       d_fd=((MP_TCP_t *)dd->transp.private1)->sock;
    1242     }
    1243     #else
    1244     d=(ssiInfo*)l->data;
    1245     d_fd=d->fd_read;
    12461248    #endif
    1247     FD_SET(d_fd, &mask);
    1248     if (d_fd > max_fd) max_fd=d_fd;
     1249      FD_SET(d_fd, &mask);
     1250      if (d_fd > max_fd) max_fd=d_fd;
     1251    }
    12491252  }
    12501253  max_fd++;
     
    12861289    for(i=L->nr; i>=0; i--)
    12871290    {
    1288       l=(si_link)L->m[i].Data();
    1289       #ifdef HAVE_MPSR
    1290       if (strcmp(l->m->type,"ssi")!=0)
    1291       {
    1292         // for MP links, return here:
    1293         dd=(MP_Link_pt)l->data;
    1294         d_fd=((MP_TCP_t *)dd->transp.private1)->sock;
    1295         if(j==d_fd) return i+1;
    1296       }
    1297       else
    1298       {
     1291      if (L->m[i].rtyp==LINK_CMD)
     1292      {
     1293        l=(si_link)L->m[i].Data();
     1294        #ifdef HAVE_MPSR
     1295        if (strcmp(l->m->type,"ssi")!=0)
     1296        {
     1297          // for MP links, return here:
     1298          dd=(MP_Link_pt)l->data;
     1299          d_fd=((MP_TCP_t *)dd->transp.private1)->sock;
     1300          if(j==d_fd) return i+1;
     1301        }
     1302        else
     1303        {
     1304          d=(ssiInfo*)l->data;
     1305          d_fd=d->fd_read;
     1306          if(j==d_fd) break;
     1307        }
     1308        #else
    12991309        d=(ssiInfo*)l->data;
    13001310        d_fd=d->fd_read;
    13011311        if(j==d_fd) break;
    1302       }
    1303       #else
    1304       d=(ssiInfo*)l->data;
    1305       d_fd=d->fd_read;
    1306       if(j==d_fd) break;
    1307       #endif
     1312        #endif
     1313      }
    13081314    }
    13091315    // only ssi links:
Note: See TracChangeset for help on using the changeset viewer.