Log In
New Account
  
 
Home My Page Project Tree Code Snippets Project Openings NUTSS
 
 
Summary Tracker Lists CVS Files
 

CVS | Administration

Diff for /libnutss/examples/slinks_variable_load.c between versions 1.7 and 1.8

version 1.7, 2007/05/31 22:04:19 version 1.8, 2007/05/31 22:42:53
Line 37  void *recvthread(void *arg) { Line 37  void *recvthread(void *arg) {
     while(time < limit) {      while(time < limit) {
         if(swaplinks_recvfrom(swp, tmp, sizeof(tmp), 0, &peer, &len) > 0) {          if(swaplinks_recvfrom(swp, tmp, sizeof(tmp), 0, &peer, &len) > 0) {
             time++; delta = 0;              time++; delta = 0;
               if(s) fprintf(s,"\t\tTIME at node %d: %d\n",num,time);
             newflow = (flow_t*)calloc(1,sizeof(flow_t));              newflow = (flow_t*)calloc(1,sizeof(flow_t));
             newflow->duration = atoi(strtok(tmp,";"));              newflow->duration = atoi(strtok(tmp,";"));
             newflow->weight = atoi(strtok(NULL,";"));              newflow->weight = atoi(strtok(NULL,";"));
             strncpy(newflow->source,peer.user+4,sizeof(newflow->source));              strncpy(newflow->source,peer.user+4,sizeof(newflow->source));
           sprintf(buf,"->%d/%d<->",newflow->duration,newflow->weight);            snprintf(buf,2048,"->%d:%d<->",newflow->duration,newflow->weight);
             for(ptr = flows; ptr; ptr = ptr->next) {              for(ptr = flows; ptr; ptr = ptr->next) {
        sprintf(buf,"%s%d:%d<->",buf,ptr->duration,ptr->weight);         sprintf(buf,"%s%d:%d<->",buf,ptr->duration,ptr->weight);
                 if(--ptr->duration == 0) {                  if(--ptr->duration == 0) {
                     load -= ptr->weight;                      load -= ptr->weight;
                     delta -= ptr->weight;                      delta -= ptr->weight;
          if(ptr->last){           if(ptr->last)
       ptr->last->next = ptr->next;        ptr->last->next = ptr->next;
       ptr->next->last = ptr->last;  
            }  
                     else {                      else {
       flows = ptr->next;        flows = ptr->next;
       flows->last = NULL;        flows->last = NULL;
            }             }
              if(ptr->next)
         ptr->next->last = ptr->last;
   
            if(s) fprintf(s,"%d EXPIRED FLOW from %s:d%d/w%d\n",num,ptr->source,ptr->duration,ptr->weight);             if(s) fprintf(s,"%d EXPIRED FLOW from %s:d%d/w%d\n",num,ptr->source,ptr->duration,ptr->weight);
            free(ptr);             free(ptr);
                 }                  }
Line 73  void *recvthread(void *arg) { Line 75  void *recvthread(void *arg) {
         }          }
     }      }
     if(s) fprintf(s,"%d DONE RECEIVING\n",num);      if(s) fprintf(s,"%d DONE RECEIVING\n",num);
   
       pthread_exit(NULL);
 }  }
   
 int main(int argc, char **argv) {  int main(int argc, char **argv) {
Line 126  int main(int argc, char **argv) { Line 130  int main(int argc, char **argv) {
   
     snprintf(tmp, sizeof(tmp), "%d;%d;", duration, weight);      snprintf(tmp, sizeof(tmp), "%d;%d;", duration, weight);
   
   while (time++ < limit*10) { // (i-- != 0) {    while (time++ < limit) { // (i-- != 0) {
         swaplinks_sendtoany(swp, tmp, strlen(tmp)+1, 0);          swaplinks_sendtoany(swp, tmp, strlen(tmp)+1, 0);
         sleep(1);          sleep(1);
     }      }
Line 138  int main(int argc, char **argv) { Line 142  int main(int argc, char **argv) {
     if(f) fclose(f);      if(f) fclose(f);
     if(s) fclose(s);      if(s) fclose(s);
   
   if(num == 1) system("echo \" \" | mail -s\"experiment done!\" ths22@cs.cornell.edu");//    if(num == 1) system("echo \" \" | mail -s\"experiment done!\" ths22@cs.cornell.edu");
   
     return 0;      return 0;
 }  }

Removed from v.1.7  
changed lines
  Added in v.1.8


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
 

GForge.cis.cornell.edu is brought to you by

Cornell Computing and Information Science


Powered By GForge Collaborative Development Environment