Changeset 6c70ef in git


Ignore:
Timestamp:
Nov 3, 2010, 5:56:28 PM (14 years ago)
Author:
Andreas Steenpaß <steenpas@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '648d28f488f6ff08f5607ff229b9ad9e4a5b93c2')
Children:
5ea590e388164e5c1a86e89caca6ca5d46eb37e9
Parents:
8a4e22c96f254f73c703a940d895136b87451b5c
Message:
	new commands: waitall, waitfirst

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

Legend:

Unmodified
Added
Removed
  • Singular/extra.cc

    r8a4e22 r6c70ef  
    629629        {
    630630          Werror( "expected valid file name as a string");
    631           return FALSE;
     631          return TRUE;
     632        }
     633      }
     634  /*==================== forking experiments ======================*/
     635      if(strcmp(sys_cmd, "waitforssilinks")==0)
     636      {
     637        if ((h != NULL) && (h->Typ() == LIST_CMD) &&
     638            (h->next != NULL) && (h->next->Typ() == INT_CMD))
     639        {
     640          lists L = (lists)h->Data();
     641          int timeMillisec = (int)(long)h->next->Data();
     642          int n = slStatusSsiL(L, timeMillisec * 1000);
     643          res->rtyp = INT_CMD;
     644          res->data = (void*)n;
     645          return FALSE;
     646        }
     647        else
     648        {
     649          Werror( "expected list of open ssi links and timeout");
     650          return TRUE;
    632651        }
    633652      }
  • Singular/iparith.cc

    r8a4e22 r6c70ef  
    207207
    208208/*=================== operations with 2 args.: static proc =================*/
     209static BOOLEAN jjWAIT1ST2(leftv res, leftv u, leftv v)
     210{
     211  lists Lforks = (lists)u->Data();
     212  int t = (int)(long)v->Data();
     213  int i = slStatusSsiL(Lforks, t*1000);
     214  if ( i < 0 ) i = 0;
     215  res->data = (void*)(long)i;
     216  return FALSE;
     217}
     218/* returns 1 iff all forks are finished; 0 otherwise */
     219static BOOLEAN jjWAITALL2(leftv res, leftv u, leftv v)
     220{
     221  lists Lforks = (lists)u->Data();
     222  int timeout = 1000*(int)(long)v->Data();
     223  lists oneFork=(lists)omAllocBin(slists_bin);
     224  oneFork->Init(1);
     225  int i;
     226  int t = getTimer();
     227  int ret = 1;
     228  for (int j = 0; j <= Lforks->nr; j++)
     229  {
     230    oneFork->m[0].Copy(&Lforks->m[j]);
     231    i = slStatusSsiL(oneFork, timeout);
     232    if (i == 1)
     233    {
     234      timeout = timeout - getTimer() + t;
     235    }
     236    else { ret = 0; j = Lforks->nr+1; /* terminate the for loop */ }
     237    omFreeSize((ADDRESS)oneFork->m,sizeof(sleftv));
     238  }
     239  omFreeBin((ADDRESS)oneFork, slists_bin);
     240  res->data = (void*)(long)ret;
     241  return FALSE;
     242}
     243
    209244static BOOLEAN jjOP_IV_I(leftv res, leftv u, leftv v)
    210245{
     
    36863721
    36873722/*=================== operations with 1 arg.: static proc =================*/
     3723
     3724BOOLEAN jjWAIT1ST1(leftv res, leftv a)
     3725{
     3726  lists Lforks = (lists)a->Data();
     3727  int i = slStatusSsiL(Lforks, -1);
     3728  while (i <= 0) i = slStatusSsiL(Lforks, 10000000); /* redo this all 10 seconds */
     3729  res->data = (void*)(long)i;
     3730  return FALSE;
     3731}
     3732
     3733BOOLEAN jjWAITALL1(leftv res, leftv a)
     3734{
     3735  lists Lforks = (lists)a->Data();
     3736  lists oneFork=(lists)omAllocBin(slists_bin);
     3737  oneFork->Init(1);
     3738  int i;
     3739  for (int j = 0; j <= Lforks->nr; j++)
     3740  {
     3741    oneFork->m[0].Copy(&Lforks->m[j]);
     3742    i = slStatusSsiL(oneFork, -1);
     3743    while (i != 1) i = slStatusSsiL(oneFork, 10000000); /* redo this all 10 seconds */
     3744    omFreeSize((ADDRESS)oneFork->m,sizeof(sleftv));
     3745  }
     3746  omFreeBin((ADDRESS)oneFork, slists_bin);
     3747  return FALSE;
     3748}
     3749
    36883750static BOOLEAN jjDUMMY(leftv res, leftv u)
    36893751{
  • Singular/ssiLink.cc

    r8a4e22 r6c70ef  
    11171117  struct timeval wt;
    11181118  int i;
    1119   for(i=L->nr-1; i>=0; i--)
     1119  for(i=L->nr; i>=0; i--)
    11201120  {
    11211121    if (L->m[i].Typ()!=LINK_CMD)
     
    11251125    { WerrorS("all links must be open"); return -2;}
    11261126    if ((strcmp(l->m->type,"ssi")!=0)
    1127     && (strcmp(l->mode,"fork")!=0) || (strcmp(l->mode,"tcp")!=NULL))
     1127    || ((strcmp(l->mode,"fork")!=0) && (strcmp(l->mode,"tcp")!=NULL)))
    11281128    { WerrorS("all links must be of type ssi:fork or ssi:tcp"); return -2;}
    11291129    d=(ssiInfo*)l->data;
     
    11311131    if (d->fd_read> max_fd) max_fd=d->fd_read;
    11321132  }
     1133  max_fd++;
    11331134  struct timeval *wt_ptr=&wt;
    11341135  if (timeout== -1)
     
    11521153    int j=0;
    11531154    while (j<=max_fd) { if (FD_ISSET(j,&mask)) break; j++; }
    1154     for(i=L->nr-1; i>=0; i--)
     1155    for(i=L->nr; i>=0; i--)
    11551156    {
    11561157      l=(si_link)L->m[i].Data();
  • Singular/table.h

    r8a4e22 r6c70ef  
    266266,{D(jjLOAD1),      LOAD_CMD,        NONE,           STRING_CMD    , ALLOW_PLURAL |ALLOW_RING}
    267267,{D(loNewtonP),    NEWTONPOLY_CMD,  IDEAL_CMD,      IDEAL_CMD     , ALLOW_PLURAL |ALLOW_RING}
     268,{D(jjWAIT1ST1),   WAIT1ST_CMD,     INT_CMD,        LIST_CMD      , ALLOW_PLURAL |ALLOW_RING}
     269,{D(jjWAITALL1),   WAITALL_CMD,     NONE,           LIST_CMD      , ALLOW_PLURAL |ALLOW_RING}
    268270#ifdef HAVE_FANS
    269271//,{D(jjDELMCONE1),  DELMCONE_CMD,    NONE,           FAN_CMD       , ALLOW_PLURAL |ALLOW_RING}
     
    644646,{D(jjVARSTR2),   VARSTR_CMD,     STRING_CMD,     RING_CMD,   INT_CMD, ALLOW_PLURAL |ALLOW_RING}
    645647,{D(jjVARSTR2),   VARSTR_CMD,     STRING_CMD,     QRING_CMD,  INT_CMD, ALLOW_PLURAL |ALLOW_RING}
     648,{D(jjWAIT1ST2),  WAIT1ST_CMD,    INT_CMD,        LIST_CMD,   INT_CMD, ALLOW_PLURAL |ALLOW_RING}
     649,{D(jjWAITALL2),  WAITALL_CMD,    INT_CMD,        LIST_CMD,   INT_CMD, ALLOW_PLURAL |ALLOW_RING}
    646650,{D(jjWEDGE),     WEDGE_CMD,      MATRIX_CMD,     MATRIX_CMD, INT_CMD, NO_PLURAL |ALLOW_RING}
    647651#ifdef HAVE_FANS
     
    10761080  { "vdim",        0, VDIM_CMD ,          CMD_1},
    10771081  { "vector",      0, VECTOR_CMD ,        RING_DECL},
     1082  { "waitfirst",   0, WAIT1ST_CMD ,       CMD_12},
     1083  { "waitall",     0, WAITALL_CMD ,       CMD_12},
    10781084  { "wedge",       0, WEDGE_CMD ,         CMD_2},
    10791085  { "weight",      0, WEIGHT_CMD ,        CMD_1},
  • Singular/tok.h

    r8a4e22 r6c70ef  
    159159  VARIABLES_CMD,
    160160  VARSTR_CMD,
     161  WAIT1ST_CMD,
     162  WAITALL_CMD,
    161163  WRITE_CMD,
    162164  /* start system var section: VECHO */
Note: See TracChangeset for help on using the changeset viewer.