Beispiel #1
0
static int def_handle_credfree(struct provmsg *msg, void *arg)
{
	struct args *args = (struct args *) arg;
	if (!want_cred(args, msg->cred_id))
		return 0;
	if (args->creds)
		removeitem(&args->extracreds, msg->cred_id);
	return 0;
}
Beispiel #2
0
void eventlist::doevent(){

    if((head)&&(currtime>=head->time)){
        head->doevent();
        removeitem(head);
        eventlist::doevent();   // may be two events at the same time or
                                // need to do 'catch-up' for some reason.
                                // hopefully won't recurse TOO much.
    }
}
Beispiel #3
0
static int handle_credfree(struct provmsg *msg, void *arg)
{
	struct provmsg_credfree *m = (struct provmsg_credfree *) msg;
	struct args *args = (struct args *) arg;
	if (!want_cred(args, msg->cred_id))
		return 0;
	if (args->creds)
		removeitem(&args->extracreds, msg->cred_id);
	printf("[%x] credfree\n", m->msg.cred_id);
	return 0;
}
Beispiel #4
0
void eventlist::removeevent(monstclass *mon,uchar type){
    eventitem *tmp1,*tmp;

    tmp=head;
    while(tmp!=NULL){
        if((tmp->mon==mon)&&(tmp->item()==type)){
            removeitem(tmp);
            return;
        } else
            tmp=tmp->next;
    }
}
Beispiel #5
0
void eventlist::removeeventformon(monstclass *m){
    eventitem *tmp,*tmp1;

    tmp=head;
    while(tmp!=NULL){   
        if(tmp->mon==m){
            tmp1=tmp;
            tmp=tmp->next;
            removeitem(tmp1);
        } else
            tmp=tmp->next;
    }
}
Beispiel #6
0
static int def_handle_exec(struct provmsg *msg, void *arg)
{
	struct args *args = (struct args *) arg;
	if (args->creds && !hasitem(args->creds, msg->cred_id)) {
		if (args->recurse < 2) {
			removeitem(&args->extracreds, msg->cred_id);
			return 0;
		} else if (!hasitem(args->extracreds, msg->cred_id)) {
			return 0;
		}
	}
	return 0;
}
Beispiel #7
0
int	toggle(int sel)
{
	int	which;

	if ((which=isselected(sel+1))!=0)
	{
		if (which<=defaultmodule)
			defaultmodule--;
		return removeitem(which-1);
	}
	else
		return additem(sel+1);
}
Beispiel #8
0
void eventlist::addevent(eventitem *d){
    eventitem *tmp;

//  need something..
//    assert(d!=NULL);
    
    // make it an absolute time, not an interval
    d->time+=currtime;

    tmp=find(d->item(),d->mon);
    // if it exists already, decide which is bigger.
    if(tmp)
        if(tmp->time<d->time)
            // if the existing time is smaller, remove it and add new like
            // normal.
            removeitem(tmp);
        else{
            // otherwise new one is useless. delete it and return.
            delete d;
            return;
        }
    // Add new item in chronological order.
    if(!head)
        // Nothing in the list. Add it first (trivial case).
        head=d;
    // list has 1 or more items.
    tmp=head;
    while((tmp->next!=NULL)&&(tmp->time<d->time))
        tmp=tmp->next;
    // tmp is either the last item or on the item to insert in front of
    
    if(!tmp->next){
        // last item
        // does it go before or after?
        if(tmp->time<d->time){
            // goes after
            tmp->next=d;
            d->prev=tmp;
        }
    }
    else {
        // tmp is on item to place in front of.
        d->next=tmp;
        d->prev=tmp->prev;
        tmp->prev=d;
        // prev is not gauranteed
        if(d->prev)
            d->prev->next=d;
    } 

}                                                               
Beispiel #9
0
static int handle_exec(struct provmsg *msg, void *arg)
{
	struct provmsg_exec *m = (struct provmsg_exec *) msg;
	struct args *args = (struct args *) arg;
	if (args->creds && !hasitem(args->creds, msg->cred_id)) {
		if (args->recurse < 2) {
			removeitem(&args->extracreds, msg->cred_id);
			return 0;
		} else if (!hasitem(args->extracreds, msg->cred_id)) {
			return 0;
		}
	}
	printf("[%x] exec ", m->msg.cred_id);
	print_sb_inode(&m->inode);
	printf(" ");

	fwrite(m->argv_envp, msg_getlen(msg) - sizeof(*m), 1, stdout);
	printf("\n");
	return 0;
}
void send_collect(WSET *ws, int num_group, int stages, int cnt_stage, 
                  int numbprocs, int cnt_step, IDLE_ELEMENT **ie, 
                  LISTELEMENT **listpointer, int *TaskCount, int NUM_GROUP, 
                  int *cnt_index, int update_flag, int n1, int n2, int cd)
{
   int slv,flght,flag,*buffer,*package,count,cnt_count,
       idle_procs[numbprocs],idle_pos,cnt_idle,
       r,c,s_max,s_min,
       deg,n=cd,m[2],send[3],label_sol,fail,i=0,j=0;
   double sol1[2*n1+5], sol2[2*n2+5], ps[2*cd+5];
   WSET *ws_p;
   JOB *temp_j;
   MPI_Status status;
   
   if(v>3) printf("inside of send_collect\n"); fflush;
   temp_j = (JOB *)((*listpointer)->dataitem); 
   count = temp_j->num_eqns_1 + temp_j->num_eqns_2 + 8; 
   if(cnt_step==2 && update_flag) 
   {   
     package = (int*) malloc(count*sizeof(int));
     pack(count, temp_j, package);    
   } 
   
   cnt_idle = num_idle(*ie);
   /* Initial JOB distribution  */
   while(*ie != NULL)                 /* there are idle processors */
   {                                     
   if(*listpointer!=NULL)            /* JOB queue is not empty */
     {
     /* pop one JOB from the queue */
     *listpointer = removeitem (*listpointer);
     slv = (*ie)->data;
     *ie = removeslv(*ie);
     /* obtain start solution & send */
     if(v>3) printf("sent a job & path to node %d.\n",slv);
     if(cnt_step==1)
     {   
     if(v>3)
         fail = get_next_start_product
                     (&i,&j,1,temp_j->num_vars_1,temp_j->num_vars_2,
                      temp_j->dim_1,temp_j->dim_2,
                      temp_j->deg_1,temp_j->deg_2,cd,sol1,sol2,ps);
     else
         fail = get_next_start_product
                     (&i,&j,0,temp_j->num_vars_1,temp_j->num_vars_2,
                      temp_j->dim_1,temp_j->dim_2,
                      temp_j->deg_1,temp_j->deg_2,cd,sol1,sol2,ps);
     m[0] = n;  m[1] = 1;
     send[0] = slv; send[1] = m[1]; send[2] = m[0];
     MPI_Send(send,3,MPI_INT,slv,SEND_SMUL,MPI_COMM_WORLD);
     MPI_Send(ps,2*n+5,MPI_DOUBLE,slv,SEND_SSOL,MPI_COMM_WORLD);
     }
     if(cnt_step==2)
     {
      fail = solcon_read_next_solution(n,&m[1],ps);
      if(fail>0) printf("solcon_read_next_solution fail!\n");
      m[0] = n; 
      send[0] = slv; send[1] = m[1]; send[2] = m[0];
      MPI_Send(send,3,MPI_INT,slv,SEND_SMUL,MPI_COMM_WORLD);
      MPI_Send(ps,2*n+5,MPI_DOUBLE,slv,SEND_SSOL,MPI_COMM_WORLD); 
     }
     /* end of obtaining start solution & sending */
     *(TaskCount+slv-1)=*(TaskCount+slv-1)+1;
     } 
   else
     break;
   }
   flght = cnt_idle - num_idle(*ie);
   
   flag = 0;
   while(flght>0 || *listpointer!=NULL)    /* JOB queue loop */
   {    
    if(flght>0)
    {
     MPI_Iprobe(MPI_ANY_SOURCE,MPI_ANY_TAG,MPI_COMM_WORLD,&flag,&status); 
     while(flag) /* while flag -- pending recv */
       {  
        if(v>3) printf("manager starting recv... \n");   
        slv = status.MPI_SOURCE;    /* which slave sent this JOB back */
        /* recv end solution */   
        MPI_Recv(ps,2*n+7,MPI_DOUBLE,MPI_ANY_SOURCE,SEND_TSOL,
                 MPI_COMM_WORLD,&status);
        m[1] = (int) ps[2*n+5];
        label_sol = (int) ps[2*n+6] - 1;
        fail = solcon_write_next_solution_to_defined_output_file
               (&label_sol,n,m[1],ps);
        /* end of recv. end solution */
        
        /* update idle processor list */
        *ie = addslv(*ie, slv);
        
        /* update corresponding cell when cnt_step==2 && update_flag is TRUE */
        if(cnt_step==2 && update_flag) 
        {
         c = cnt_stage;
         r = *cnt_index;
                  
         ws_p = ws+r*(stages+1)+c; 
        
         if(ws_p->count==0)    /* first returned JOB for current witness set */
         { 
          printf("update num_eqns, source, dim, deg\n");   
          ws_p->num_eqns = package[0];
          ws_p->source = (int*) malloc(package[0]*sizeof(int));
          deg = 1;
          for(cnt_count=0;cnt_count<package[0];cnt_count++)
          {
           ws_p->source[cnt_count] = package[cnt_count+1];
           printf("ws[%d][%d].source[%d]=%d\n",r,c,cnt_count,ws_p->source[cnt_count]);
           deg = (ws+(package[cnt_count+1]-1)*(stages+1))->deg*deg;
          }
          ws_p->dim = package[package[0]+1];
          /*ws_p->sols = (int*) malloc(deg*sizeof(int));*/
          ws_p->deg = deg;
         }  
         /*ws_p->sols[ws_p->count]=ws_p->count+1; */
         ws_p->count++;
        
         if(ws_p->count==ws_p->deg)     /* this witness set is complete */
         {          
          if(ws_p->num_eqns==NUM_GROUP) 
           {
            printf("\nrecord [%d][%d]\n", r,c);
            printf("ALL DONE! aha........\n");
            print_ws(ws_p); 
           }  
         }      /* if: count==deg */
        }       /* cnt_step == 2 && update_flag */               
                  
        if(*listpointer!=NULL)              /* JOB queue is not empty */
        {
          /* pop one JOB from the queue */
          *listpointer = removeitem (*listpointer);
          slv = (*ie)->data;
          *ie = removeslv(*ie); 
          if(v>3) printf("sending a job & path to node %d.\n",slv);         
          /* obtain start solution & send */
          if(cnt_step==1)
          {
           if(v>3)
             fail = get_next_start_product
                     (&i,&j,1,temp_j->num_vars_1,temp_j->num_vars_2,
                      temp_j->dim_1,temp_j->dim_2,
                      temp_j->deg_1,temp_j->deg_2,cd,sol1,sol2,ps);
           else
             fail = get_next_start_product
                     (&i,&j,0,temp_j->num_vars_1,temp_j->num_vars_2,
                      temp_j->dim_1,temp_j->dim_2,
                      temp_j->deg_1,temp_j->deg_2,cd,sol1,sol2,ps);
             m[0] = n;  m[1] = 1;
             send[0] = slv; send[1] = m[1]; send[2] = m[0];
             MPI_Send(send,3,MPI_INT,slv,SEND_SMUL,MPI_COMM_WORLD);
             MPI_Send(ps,2*n+5,MPI_DOUBLE,slv,SEND_SSOL,MPI_COMM_WORLD);
          }
          if(cnt_step==2)
          {
            fail = solcon_read_next_solution(n,&m[1],ps);
            m[0] = n; 
            send[0] = slv; send[1] = m[1]; send[2] = m[0];
            MPI_Send(send,3,MPI_INT,slv,SEND_SMUL,MPI_COMM_WORLD);
            MPI_Send(ps,2*n+5,MPI_DOUBLE,slv,SEND_SSOL,MPI_COMM_WORLD); 
          }   
          /* end of obtaining start solution & sending */
          *(TaskCount+slv-1)=*(TaskCount+slv-1)+1; 
        }
        else                       /* JOB queue is empty */
        {
          flght=flght-1;           /* one in-flight task less */         
          if(v>3)
          {printf ("Job queue empty!\n");        
           printf("flght=%d\n",flght);
          }  
        }
        MPI_Iprobe(MPI_ANY_SOURCE,MPI_ANY_TAG,MPI_COMM_WORLD,&flag,&status);
       } /* while flag */
    } /* if flght */  
   }  /* while flght listpointer */
   /* send termination to all workers */
   if(v>3) printf("\nmanager sent termination\n");
   for(slv=1;slv<=numbprocs-1;slv++)
   {
    count = -1; 
    MPI_Send(&count,1,MPI_INT,slv,COUNT_TAG,MPI_COMM_WORLD);
   } 
}