[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: CommsTime times?



Dyke/Oyvind et al.,

We tried measuring the commstime on our StrongARM system.
The codes were obtained from Jim previously, and there's a slight
modification to suit the 3L libraries which we've implemented. There's no
difference, except for the syntax.

The results obtained are as follow:
When those processes were executed in high priority:
Time per loop : 17.4136 microsecond
Dividing by 8 to get context switch time
Time per context switch : 2.177 microsecond

When those processes were executed in low priority:
Time per loop : 32.5976 microsecond
Time per context switch : 4.075 microsecond

The difference is because when high priority are context-switched, no
request is made to the timer module to generate a timer interrupt, since
high priority queue is not time sliced. It's the opposite for the low
priority queue. Therefore, the low priority queue incurs a higher overhead.




The codes, where delta is sequential:
note : the commented codes indicate the original codes, and the code below
it indicates 3L library call
//--------------------------------------------------------------------------
----------------
void Prefix (Process *p, int n, Channel *in, Channel *out) {
  int value;
  ChanOutInt(out, n);    
  while (1) {
    //value = ChanInInt(in);
    chan_in_byte(&value,in);    
    ChanOutInt(out, value);
   
  }
}

void Delta (Process *p, Channel *in, Channel *out_1, Channel *out_2) {  
  int value;
  while (1) {
    //value = ChanInInt(in);    
    chan_in_byte(&value,in);    
    ChanOutInt(out_1, value);    
    ChanOutInt(out_2, value); /* in sequence for now... */
    
  }
}

void Succ (Process *p, Channel *in, Channel *out) {
  int value;
  while (1) {
    //value = ChanInInt(in);
    chan_in_byte(&value,in);    
    ChanOutInt(out, value+1);
  }
}


void Nos (Process *p, Channel *out) {
  
  Channel *a = ChanAlloc();
  Channel *b = ChanAlloc();
  Channel *c = ChanAlloc();
  /*
  Process *prefix = ProcAlloc(Prefix, 655360, 3, 0, b, a);
  Process *delta = ProcAlloc(Delta, 655360, 3, a, c, out);
  Process *succ = ProcAlloc(Succ, 655360, 2, c, b);  
  */
  thread_create(Prefix, 655360, 4,0, 0, b, a);
  thread_create(Delta, 655360, 4,0, a, c, out);
  thread_create(Succ, 655360, 3,0, c, b);
  
  //ProcPar(prefix, delta, succ, NULL);

}

void Consume (Process *p, int nLoops, Channel *in) {
  Time t0, t1;
  int i, value;
  //fprintf(stderr, "Commstime in C ...\n");  
  for (i=0; i<16; i++) {
    //value = ChanInInt(in);
    chan_in_byte(&value,in);    
  }
  //t0 = ProcTime();
  t0 = timer_now();
  
  for (i=0; i< nLoops; i++) {
    //value = ChanInInt(in);
    chan_in_byte(&value,in);
  }
  //t1 = ProcTime();
  t1 = timer_now();
  /*
  fprintf(stderr,"Last value received = %d\n", value);
  fprintf(stderr,"Time = %d microseconds.", t1-t0);
  fprintf(stderr,"Loops = %d.\n",nLoops);
  fprintf(stderr,"Time per loop = %f microseconds.\n", 
                  ((double)(t1-t0)/Time_ticks_per_us_d)/(double)nLoops);
  fprintf(stderr,"Average context switch/communication = %d nanoseconds", 
                  (int)( (
((double)(ProcTimeMinus(t1,t0)/Time_ticks_per_us_d)/(double)nLoops)
/8)*1000));
  */
  
  printf("Last value received = %d\n", value);  
  printf("Time = %d microseconds, with initial time :%d, end time %d.",
t1-t0,t0,t1);
  printf("Loops = %d.\n",nLoops);  
  printf("Time per loop = %d
microseconds.\n",((t1-t0)/Time_ticks_per_us_d)/nLoops);
  printf("Average context switch/communication = %d nanoseconds",\
  (((t1-t0)/Time_ticks_per_us_d)/nLoops/8)*1000);  
}

void RunMain(Process *p) {
  Channel *c = ChanAlloc();
  //Process *nos = ProcAlloc(Nos, 65536, 1, c);
  thread_create(Nos,65536,2,0,c);
  
  
  //Process *consume = ProcAlloc(Consume, 65536, 2, 1000000, c);  
  thread_create(Consume, 65536,3,0, 100000, c);
  //ProcPar(nos, consume, NULL);
}