⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 disksim_iodriver.c

📁 目前最精确的磁盘模拟器的第3版
💻 C
📖 第 1 页 / 共 3 页
字号:
         }      }   }}static void get_device_maxoutstanding (iodriver *curriodriver, device * dev){   ioreq_event *chk = (ioreq_event *) getfromextraq();   chk->busno = dev->buspath.value;   chk->slotno = dev->slotpath.value;   chk->devno = dev->devno;   chk->type = IO_QLEN_MAXCHECK;   iodriver_send_event_down_path(chk);   dev->queuectlr = chk->tempint1;   dev->maxoutstanding = (chk->tempint1 == -1) ? chk->tempint2 : -1;   if (chk->tempint1 != -1) {      curriodriver->ctlrs[chk->tempint1].maxoutstanding = chk->tempint2;      curriodriver->ctlrs[chk->tempint1].maxreqsize = chk->bcount;   }/*   fprintf (outputfile, "Maxoutstanding: tempint1 %d, tempint2 %d, bcount %d\n", chk->tempint1, chk->tempint2, chk->bcount);*/   addtoextraq((event *) chk);}#if 0static void print_paths_to_devices(){   int i,j;   for (i = 0; i < numiodrivers; i++) {      fprintf (outputfile, "I/O driver #%d\n", i);      for (j = 0; j < iodrivers[i]->numdevices; j++) {         fprintf (outputfile, "Device #%d: buspath = %x, slotpath = %x\n", j, iodrivers[i]->devices[j].buspath.value, iodrivers[i]->devices[j].slotpath.value);      }   }}#endif#if 0static void print_paths_to_ctlrs(){   int i,j;   for (i = 0; i < numiodrivers; i++) {      fprintf (outputfile, "I/O driver #%d\n", i);      for (j = 0; j < iodrivers[i]->numctlrs; j++) {         fprintf (outputfile, "Controller #%d: buspath = %x, slotpath = %x\n", j, iodrivers[i]->ctlrs[j].buspath.value, iodrivers[i]->ctlrs[j].slotpath.value);      }   }}#endifvoid iodriver_setcallbacks (){   ioqueue_setcallbacks();}void iodriver_initialize (int standalone){   int numdevs;   struct ioq * queueset[MAXDEVICES];   int i, j;   iodriver *curriodriver;      /* Code will be broken by multiple iodrivers */   ASSERT1(numiodrivers == 1, "numiodrivers", numiodrivers);   ioqueue_initialize (overallqueue, 0);   for (i = 0; i < numiodrivers; i++) {      curriodriver = iodrivers[i];      curriodriver->type = standalone;      if (standalone != STANDALONE) {         curriodriver->scale = 1.0;      }      numdevs = controller_get_numcontrollers();      curriodriver->numctlrs = numdevs;      curriodriver->ctlrs = (ctlr*) DISKSIM_malloc(numdevs * (sizeof(ctlr)));      ASSERT(curriodriver->ctlrs != NULL);      for (j=0; j < numdevs; j++) {         ctlr *currctlr = &curriodriver->ctlrs[j];         currctlr->ctlno = j;         currctlr->flags = 0;         if (controller_C700_based(j) == TRUE) {/*fprintf (outputfile, "This one is c700_based - %d\n", j);*/            currctlr->flags |= DRIVER_C700;         }         currctlr->buspath.value = 0;         currctlr->slotpath.value = 0;         iosim_get_path_to_controller(i, currctlr->ctlno, &currctlr->buspath, &currctlr->slotpath);         currctlr->numoutstanding = 0;         currctlr->pendio = NULL;         currctlr->oversized = NULL;      }      numdevs = device_get_numdevices();      curriodriver->numdevices = numdevs;      curriodriver->devices = (device*) DISKSIM_malloc(numdevs * (sizeof(device)));      ASSERT(curriodriver->devices != NULL);      for (j = 0; j < numdevs; j++) {         device *currdev = &curriodriver->devices[j];         currdev->devno = j;         currdev->busy = FALSE;         currdev->flag = 0;         currdev->queue = ioqueue_copy(curriodriver->queue);         ioqueue_initialize(currdev->queue, j);         queueset[j] = currdev->queue;         currdev->buspath.value = 0;         currdev->slotpath.value = 0;         iosim_get_path_to_device(i, currdev->devno, &currdev->buspath, &currdev->slotpath);         iodriver_set_ctl_to_device(i, currdev);         get_device_maxoutstanding(curriodriver, currdev);      }      logorg_initialize(sysorgs, numsysorgs, queueset,			drv_printlocalitystats, 			drv_printblockingstats, 			drv_printinterferestats, 			drv_printstreakstats, 			drv_printstampstats, 			drv_printintarrstats, 			drv_printidlestats, 			drv_printsizestats);/*fprintf (outputfile, "Back from logorg_initialize\n");*/   }   stat_initialize(statdeffile, statdesc_emptyqueue, &emptyqueuestats);   stat_initialize(statdeffile, statdesc_initiatenext, &initiatenextstats);#if 0   print_paths_to_devices();   print_paths_to_ctlrs();#endif}void iodriver_resetstats(){   int i, j;   int numdevs = device_get_numdevices();   ioqueue_resetstats(overallqueue);   for (i=0; i<numiodrivers; i++) {      for (j=0; j<numdevs; j++) {         ioqueue_resetstats(iodrivers[i]->devices[j].queue);      }   }   logorg_resetstats(sysorgs, numsysorgs);   stat_reset(&emptyqueuestats);   stat_reset(&initiatenextstats);}int disksim_iodriver_stats_loadparams(struct lp_block *b) {    if (disksim->iodriver_info == NULL) {    disksim->iodriver_info = DISKSIM_malloc (sizeof(iodriver_info_t));    bzero ((char *)disksim->iodriver_info, sizeof(iodriver_info_t));  }      /*     unparse_block(b, outputfile); */  #include "modules/disksim_iodriver_stats_param.c"    return 1;}static iodriver *driver_copy(iodriver *orig);static void add_driver(iodriver *d) {  int c, newlen,zerocnt;  for(c = 0; c < disksim->iodriver_info->iodrivers_len; c++) {    if(!iodrivers[c]) {      iodrivers[c] = d;      return;    }  }  newlen = c ? 2*c : 2;  disksim->iodriver_info->iodrivers_len = newlen;  iodrivers = realloc(iodrivers, newlen * sizeof(iodriver *));  zerocnt = c ? c : 2;  bzero((struct iodriver*)iodrivers + c, zerocnt * sizeof(iodriver *));  iodrivers[c] = d;  numiodrivers++;}struct iodriver *disksim_iodriver_loadparams(struct lp_block *b) {  iodriver *result;  if (disksim->iodriver_info == NULL) {    disksim->iodriver_info = malloc (sizeof(iodriver_info_t));    bzero ((char *)disksim->iodriver_info, sizeof(iodriver_info_t));  }  overallqueue = ioqueue_createdefaultqueue ();     result = malloc(sizeof(iodriver));  bzero(result, sizeof(iodriver));  add_driver(result);  result->name = strdup(b->name);#include "modules/disksim_iodriver_param.c"  result->scale = 0.0;  return result;}int load_iodriver_topo(struct lp_topospec *t) {  struct iodriver *id;  assert(!strcmp(t->type, disksim_mods[DISKSIM_MOD_IODRIVER]->name));  id = getiodriverbyname(t->name, 0);  if(!id) {    fprintf(stderr, "*** error: no such iodriver %s\n", t->name);    return 0;  }  if(t->l->values_len < 1) {    fprintf(stderr, "*** error: currently, exactly one bus must be connected to a device driver.\n");    return 0;  }  else if(t->l->values_len > 1) {    if(disksim->verbosity > 0)       fprintf(stderr, "*** warning: currently, only one bus is supported per device driver.  I'm ignoring the rest of the buses.\n");  }  if(t->l->values[0]->t != TOPOSPEC) {    fprintf(stderr, "*** error: bad bus spec for device driver.\n");    return 0;  }  if(strcmp(lp_lookup_base_type(t->l->values[0]->v.t.l[0].type, 0), 	    disksim_mods[DISKSIM_MOD_BUS]->name))     {      fprintf(stderr, "*** error: must attach buses to device driver.\n");      return 0;    }  if(!getbusbyname(t->l->values[0]->v.t.l[0].name, &id->outbus)) {    fprintf(stderr, "*** error: no such bus %s.\n", 	    t->l->values[0]->v.t.l[0].name);    return 0;  }  id->numoutbuses = 1;  /* ghetto! */  bus_set_to_zero_depth(id->outbus);  return load_bus_topo(&t->l->values[0]->v.t.l[0], 0);}static iodriver *driver_copy(iodriver *orig) {  iodriver *result = malloc(sizeof(iodriver));  bzero(result, sizeof(iodriver));  memcpy(result, orig, sizeof(iodriver));  result->queue = ioqueue_copy(orig->queue);  return result;}int iodriver_load_logorg(struct lp_block *b) {  int c, newlen, zeroOff;    struct logorg *l = 0;  newlen = disksim->iodriver_info->sysorgs_len ?     disksim->iodriver_info->sysorgs_len * 2 : 2;  zeroOff = (newlen == 2) ? 0 : (newlen / 2);  l = disksim_logorg_loadparams(b);   if(!l) return 0;  for(c = 0; c < disksim->iodriver_info->sysorgs_len; c++) {    if(!sysorgs[c]) {      goto foundslot;    }  }  sysorgs = realloc(sysorgs, newlen * sizeof(struct logorg *));  bzero(sysorgs + zeroOff, 	(zeroOff ? numsysorgs : 2) * sizeof(struct logorg *));  disksim->iodriver_info->sysorgs_len = newlen; foundslot:  sysorgs[c] = l;  logorg_set_arraydisk(l, c);  numsysorgs++;  return 1;}void iodriver_printstats(){   int i;   int j;   struct ioq **queueset;   int setsize = 0;   char prefix[80];   fprintf (outputfile, "\nOVERALL I/O SYSTEM STATISTICS\n");   fprintf (outputfile, "-----------------------------\n\n");   sprintf (prefix, "Overall I/O System ");   ioqueue_printstats (&overallqueue, 1, prefix);   fprintf (outputfile, "\nSYSTEM-LEVEL LOGORG STATISTICS\n");   fprintf (outputfile, "------------------------------\n\n");   sprintf(prefix, "System ");   logorg_printstats(sysorgs, numsysorgs, prefix);   fprintf (outputfile, "\nIODRIVER STATISTICS\n");   fprintf (outputfile, "-------------------\n\n");   for (i = 0; i < numiodrivers; i++) {      setsize += iodrivers[i]->numdevices;   }   queueset = (struct ioq **)DISKSIM_malloc(setsize*sizeof(struct ioq *));   setsize = 0;   for (i = 0; i < numiodrivers; i++) {      for (j = 0; j < iodrivers[i]->numdevices; j++) {         queueset[setsize] = iodrivers[i]->devices[j].queue;         setsize++;      }   }   sprintf(prefix, "IOdriver ");   if (stat_get_count(&emptyqueuestats) > 0) {      stat_print(&emptyqueuestats, prefix);   }   if (stat_get_count(&initiatenextstats) > 0) {      stat_print(&initiatenextstats, prefix);   }   ioqueue_printstats(queueset, setsize, prefix);   if ((drv_printperdiskstats == TRUE) && ((numiodrivers > 1) || (iodrivers[0]->numdevices > 1))) {      for (i = 0; i < numiodrivers; i++) {         for (j = 0; j < iodrivers[i]->numdevices; j++) {            fprintf (outputfile, "\nI/O Driver #%d - Device #%d\n", i, j);            sprintf(prefix, "IOdriver #%d device #%d ", i, j);            ioqueue_printstats(&iodrivers[i]->devices[j].queue, 1, prefix);         }      }   }   free(queueset);}void iodriver_cleanstats(){   int i;   int j;   ioqueue_cleanstats (overallqueue);   logorg_cleanstats(sysorgs, numsysorgs);   for (i = 0; i < numiodrivers; i++) {      for (j = 0; j < iodrivers[i]->numdevices; j++) {         ioqueue_cleanstats(iodrivers[i]->devices[j].queue);      }   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -