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

📄 disksim_iosim.c

📁 目前最精确的磁盘模拟器的第3版
💻 C
📖 第 1 页 / 共 2 页
字号:
/*fprintf (outputfile, "devno %d, depth %d, currbus %d, inslotno %d, master %d\n", devno, depth, currbus, inslotno, master);*/      outslotno = (char) controller_get_outslot(master, currbus);      buspath->byte[depth] = (char) currbus;      slotpath->byte[depth] = (inslotno & 0x0F) | (outslotno << 4);      depth--;      currbus = controller_get_inbus(master);      inslotno = (char) controller_get_slotno(master);      master = controller_get_bus_master(currbus);          /* Bus must have at least one controller */      ASSERT1((master != -1) || (depth <= 0), "currbus", currbus);   }   outslotno = (char) iodriverno;   buspath->byte[depth] = currbus;   slotpath->byte[depth] = (inslotno & 0x0F) | (outslotno << 4);}static int iosim_load_map(struct lp_block *b, int n) {  int c;  int i = 0;  char *s = 0; #include "modules/disksim_iomap_param.c"    if (tracemap2[n] == 512) {    tracemap2[n] = 0;  }   else if (tracemap2[n] > 512) {    tracemap2[n] = -(tracemap2[n] / 512);  }   else {    tracemap2[n] = 512 / tracemap2[n];  }    return 1;}static int iosim_load_mappings(struct lp_list *l) {  int c;   int mapno = 0;  if(l->values_len > TRACEMAPPINGS) {    fprintf(stderr, "*** error: too many io mappings.\n");    return -1;  }  for(c = 0; c < l->values_len; c++) {    if(!l->values[c]) continue;    if(l->values[c]->t == BLOCK) {      assert(iosim_load_map(l->values[c]->v.b, mapno));      tracemappings++;    }    mapno++;  }  return 1;}int disksim_iomap_loadparams(struct lp_block *b) {   ddbg_assert2(0, "this is a dummy and isn't supposed to be called");  return 0;}int disksim_iosim_loadparams(struct lp_block *b) {  if(!disksim->iosim_info)     iosim_initialize_iosim_info();#include "modules/disksim_iosim_param.c"  return 1;}/* OBSELETE */void io_readparams (FILE *parfile){  ddbg_assert(0);/*     fscanf(parfile, "\nI/O Subsystem Input Parameters\n"); *//*     fprintf(outputfile, "\nI/O Subsystem Input Parameters\n"); *//*     fscanf(parfile, "------------------------------\n"); *//*     fprintf(outputfile, "------------------------------\n"); *//*     fscanf(parfile, "\nPRINTED I/O SUBSYSTEM STATISTICS\n\n"); *//*     fprintf(outputfile, "\nPRINTED I/O SUBSYSTEM STATISTICS\n\n"); *//*     iodriver_read_toprints(parfile); *//*     bus_read_toprints(parfile); *//*     controller_read_toprints(parfile); *//*     device_read_toprints(parfile); *//*     fscanf(parfile, "\nGENERAL I/O SUBSYSTEM PARAMETERS\n\n"); *//*     fprintf(outputfile, "\nGENERAL I/O SUBSYSTEM PARAMETERS\n\n"); *//*     io_read_generalparms(parfile); *//*     fscanf(parfile, "\nCOMPONENT SPECIFICATIONS\n"); *//*     fprintf(outputfile, "\nCOMPONENT SPECIFICATIONS\n"); *//*     iodriver_read_specs(parfile); *//*     bus_read_specs(parfile); *//*     controller_read_specs(parfile); *//*     device_read_specs(parfile); *//*     fscanf(parfile, "\nPHYSICAL ORGANIZATION\n"); *//*     fprintf(outputfile, "\nPHYSICAL ORGANIZATION\n"); *//*     iodriver_read_physorg(parfile); *//*     controller_read_physorg(parfile); *//*     bus_read_physorg(parfile); *//*     fscanf(parfile, "\nSYNCHRONIZATION\n"); *//*     fprintf(outputfile, "\nSYNCHRONIZATION\n"); *//*     device_read_syncsets(parfile); *//*     fscanf(parfile, "\nLOGICAL ORGANIZATION\n"); *//*     fprintf(outputfile, "\nLOGICAL ORGANIZATION\n"); *//*     iodriver_read_logorg(parfile); *//*     controller_read_logorg(parfile); *//*   bus_print_phys_config();*/}void io_validate_do_stats1 (){   int i;   if (tracestats2 == NULL) {      tracestats2 = (statgen *)DISKSIM_malloc(sizeof(statgen));      tracestats3 = (statgen *)DISKSIM_malloc(sizeof(statgen));      tracestats4 = (statgen *)DISKSIM_malloc(sizeof(statgen));      tracestats5 = (statgen *)DISKSIM_malloc(sizeof(statgen));      stat_initialize(statdeffile, statdesc_traceaccstats, tracestats2);      stat_initialize(statdeffile, statdesc_traceaccdiffstats, tracestats3);      stat_initialize(statdeffile, statdesc_traceaccwritestats, tracestats4);      stat_initialize(statdeffile, statdesc_traceaccdiffwritestats, tracestats5);      for (i=0; i<10; i++) {	 validatebuf[i] = 0;      }   } else {      stat_update(tracestats3, (validate_lastserv - disksim->lastphystime));      if (!validate_lastread) {         stat_update(tracestats5, (validate_lastserv - disksim->lastphystime));      }   }}void io_validate_do_stats2 (ioreq_event *new){   stat_update(tracestats2, validate_lastserv);   if (new->flags == WRITE) {      stat_update(tracestats4, validate_lastserv);   }   if (strcmp(validate_buffaction, "Doub") == 0) {      validatebuf[0]++;   } else if (strcmp(validate_buffaction, "Trip") == 0) {      validatebuf[1]++;   } else if (strcmp(validate_buffaction, "Miss") == 0) {      validatebuf[2]++;   } else if (strcmp(validate_buffaction, "Hit") == 0) {      validatebuf[3]++;   } else {      fprintf(stderr, "Unrecognized buffaction in validate trace: %s\n", validate_buffaction);      exit(1);   }}static void io_hpl_do_stats1 (){   int i;   if (tracestats == NULL) {      tracestats  = (statgen *)DISKSIM_malloc(tracemappings * sizeof(statgen));      tracestats1 = (statgen *)DISKSIM_malloc(tracemappings * sizeof(statgen));      tracestats2 = (statgen *)DISKSIM_malloc(tracemappings * sizeof(statgen));      tracestats3 = (statgen *)DISKSIM_malloc(tracemappings * sizeof(statgen));      tracestats4 = (statgen *)DISKSIM_malloc(tracemappings * sizeof(statgen));      for (i=0; i<tracemappings; i++) {         stat_initialize(statdeffile, statdesc_tracequeuestats, &tracestats[i]);         stat_initialize(statdeffile, statdesc_tracerespstats, &tracestats1[i]);         stat_initialize(statdeffile, statdesc_traceaccstats, &tracestats2[i]);         stat_initialize(statdeffile, statdesc_traceqlenstats, &tracestats3[i]);         stat_initialize(statdeffile, statdesc_tracenoqstats, &tracestats4[i]);      }   }}void io_map_trace_request (ioreq_event *temp){   int i;   for (i=0; i<tracemappings; i++) {      if (temp->devno == tracemap[i]) {	 temp->devno = tracemap1[i];	 if (tracemap2[i]) {	    if (tracemap2[i] < 1) {	       temp->blkno *= -tracemap2[i];	    } else {	       if (temp->blkno % tracemap2[i]) {	          fprintf(stderr, "Small sector size disk using odd sector number: %d\n", temp->blkno);	          exit(1);	       }/*	       fprintf (outputfile, "mapping block number %d to %d\n", temp->blkno, (temp->blkno / tracemap2[i]));*/	       temp->blkno /= tracemap2[i];	    }	 }	 temp->bcount *= tracemap3[i];	 temp->blkno += tracemap4[i];	 if (tracestats) {	    stat_update(&tracestats[i], ((double) temp->tempint1 / (double) 1000));	    stat_update(&tracestats1[i],((double) (temp->tempint1 + temp->tempint2) / (double) 1000));	    stat_update(&tracestats2[i],((double) temp->tempint2 / (double) 1000));	    stat_update(&tracestats3[i], (double) temp->slotno);	    if (temp->slotno == 1) {	       stat_update(&tracestats4[i], ((double) temp->tempint1 / (double) 1000));	    }	 }	 return;      }   }/*   fprintf(stderr, "Requested device not mapped - %x\n", temp->devno);   exit(1);*/}event * io_get_next_external_event (FILE *iotracefile){   ioreq_event *temp;   ASSERT(io_extq == NULL);   //fprintf (outputfile, "Near beginning of io_get_next_external_event\n");   temp = (ioreq_event *) getfromextraq();   switch (disksim->traceformat) {      case VALIDATE: io_validate_do_stats1();		     break;      case HPL: io_hpl_do_stats1();                break;   }   temp = iotrace_get_ioreq_event(iotracefile, disksim->traceformat, temp);   if (temp) {      switch (disksim->traceformat) {         case VALIDATE: io_validate_do_stats2 (temp);		        break;      }      temp->type = IO_REQUEST_ARRIVE;      if (constintarrtime > 0.0) {	 temp->time = last_request_arrive + constintarrtime;	 last_request_arrive = temp->time;      }      temp->time = (temp->time * ioscale) + tracebasetime;      if ((temp->time < simtime) && (!disksim->closedios)) {         fprintf(stderr, "Trace event appears out of time order in trace - simtime %f, time %f\n", simtime, temp->time);	 fprintf(stderr, "ioscale %f, tracebasetime %f\n", ioscale, tracebasetime);	 fprintf(stderr, "devno %d, blkno %d, bcount %d, flags %d\n", temp->devno, temp->blkno, temp->bcount, temp->flags);         exit(1);      }      if (tracemappings) {         io_map_trace_request(temp);      }      io_extq = (event *)temp;      io_extq_type = temp->type;   }/*fprintf (outputfile, "leaving io_get_next_external_event\n");*/   return ((event *)temp);}int io_using_external_event (event *curr){   if (io_extq == curr) {      curr->type = io_extq_type;      io_extq = NULL;      return(1);   }   return(0);}void io_printstats(){   int i;   int cnt = 0;   char prefix[80];   fprintf (outputfile, "\nSTORAGE SUBSYSTEM STATISTICS\n");   fprintf (outputfile, "----------------------------\n");   iotrace_printstats (outputfile);   if ((tracestats) && (PRINTTRACESTATS)) {      /* info relevant to HPL traces */      for (i=0; i<tracemappings; i++) {         sprintf(prefix, "Mapped disk #%d ", i);         stat_print(&tracestats[i], prefix);         stat_print(&tracestats1[i], prefix);         stat_print(&tracestats2[i], prefix);         stat_print(&tracestats3[i], prefix);         stat_print(&tracestats4[i], prefix);      }   } else if ((tracestats2) && (PRINTTRACESTATS)) {      /* info to help with validation */      fprintf (outputfile, "\n");      stat_print(tracestats2, "VALIDATE ");      stat_print(tracestats3, "VALIDATE ");      stat_print(tracestats4, "VALIDATE ");      stat_print(tracestats5, "VALIDATE ");      for (i=0; i<10; i++) {	 cnt += validatebuf[i];      }      fprintf (outputfile, "VALIDATE double disconnects:  %5d  \t%f\n", validatebuf[0], ((double) validatebuf[0] / (double) cnt));      fprintf (outputfile, "VALIDATE triple disconnects:  %5d  \t%f\n", validatebuf[1], ((double) validatebuf[1] / (double) cnt));      fprintf (outputfile, "VALIDATE read buffer hits:    %5d  \t%f\n", validatebuf[3], ((double) validatebuf[3] / (double) cnt));      fprintf (outputfile, "VALIDATE buffer misses:       %5d  \t%f\n", validatebuf[2], ((double) validatebuf[2] / (double) cnt));   }   iodriver_printstats();   device_printstats();   controller_printstats();   bus_printstats();}void io_setcallbacks (){   device_setcallbacks ();   bus_setcallbacks ();   controller_setcallbacks ();   iodriver_setcallbacks ();}void io_initialize (int standalone){   if (disksim->iosim_info == NULL) {      iosim_initialize_iosim_info ();   }   bus_set_depths();   // fprintf (outputfile, "Back from bus_set_depths\n");   StaticAssert (sizeof(ioreq_event) <= DISKSIM_EVENT_SIZE);   device_initialize();   bus_initialize();   controller_initialize();   iodriver_initialize(standalone);}void io_resetstats(){   iodriver_resetstats();   device_resetstats();   bus_resetstats();   controller_resetstats();}void io_cleanstats(){   iodriver_cleanstats();   device_cleanstats();   bus_cleanstats();   controller_cleanstats();}

⌨️ 快捷键说明

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