Beispiel #1
0
long page_faults()
{
    long _page_faults;
    if (lib$stat_timer(&5, &_page_faults)==SS$_NORMAL)
        return(timer_initialized?_page_faults:-1);
    return(-1);
    }
Beispiel #2
0
long dio_count()
{
    long _dio_count;
    if (lib$stat_timer(&4, &_dio_count)==SS$_NORMAL)
        return(timer_initialized?_dio_count:-1);
    return(-1);
    }
Beispiel #3
0
long cpu_time()
{
    long _cputime;
    if (lib$stat_timer(&2, &_cputime)==SS$_NORMAL)
        return(timer_initialized?_cputime:-1);
    return(-1);
    }
Beispiel #4
0
char *elapsed_time()
{
    static long tbuf[2];

    if (lib$stat_timer(&1, tbuf)==SS$_NORMAL) {
        if (!timer_initialized)
            return(NULL);
        return(asc_time(tbuf, 1));
        }
    return(NULL);
    }
Beispiel #5
0
void q3(void)
{
  
  int i = 0;
    
  /* initialize the timer to keep track of customers time in shop */
  time_in_shop = stat_timer();
  
  /* initialize the counter to keep track of number of customers in the shop */
  customer_in_shop = stat_counter();
  
  /* initialize the counter to keep track of status of barber's chair*/
  bchair_stat = stat_counter();

  /* declaring the barber thread */   
  pthread_t barber;
 
  /* creating the barber thread */ 
  pthread_create(&barber, NULL, barber_thread, (void*) -1);
 
  /* declaring the customer thread */ 
  pthread_t cust;

  for( i=0; i < cust_threads; i++)
  {
      /* creating the customer thread */ 
      pthread_create(&cust , NULL, customer_thread, (void*) i);
  }

  wait_until_done();
  
  /* average number of customers turned away */
  float avg_cust = (float) cust_turned_away/total_cust_entered;
  
  /* Average number of customers in the shop */
  double avg_customer_in_shop = stat_count_mean(customer_in_shop);
  
  /* Average time spent in the shop by a customer who does not find a full shop */
  double avg_cust_time_shop = stat_timer_mean(time_in_shop);
  
  /* Fraction of time someone is siting on the barber's chair */
  double avg_bchair_stat = stat_count_mean(bchair_stat);

  printf("Fraction of customer visits result in turning away due to a full shop = %f \n", avg_cust);
  printf("Average time spent in the shop by a customer who does not find a full shop = %f \n", avg_cust_time_shop);
  printf("Average number of customers in the shop = %f \n", avg_customer_in_shop);
  printf("Fraction of time someone is siting on the barber's chair  = %f \n", avg_bchair_stat);
}