Beispiel #1
0
int
main(int argc, char *argv[])
{
	int nsectors;
	//	struct stat; 
	//	struct disksim *disksim, *disksim2;
	struct stat buf;
	int len = 8192000;
	int test_encapsulation;
	struct disksim_interface* disksim;

	struct gengetopt_args_info args_info; 

	if (argc != 4 || (nsectors = atoi(argv[3])) <= 0) {
	  fprintf(stderr, "usage: %s <param file> <output file> <#nsectors>\n",
		  argv[0]);
	  exit(1);
	}

	if (stat(argv[1], &buf) < 0)
      	  panic(argv[1]);

  //	nsectors = args_info.sectors_arg; 
	test_encapsulation = 0;//args_info.test_encapsulation_flag; 

	disksim = disksim_interface_initialize(argv[1], 
					       argv[2],
					       syssim_report_completion,
					       syssim_schedule_callback,
					       syssim_deschedule_callback,
					       0,
					       0,
					       0);

	/* This simulates the skippy algorithm */
	seek_sim(disksim, 
		 nsectors,
		 512,
		 0); 



	//	if (test_encapsulation) {
	//		disksim_interface_shutdown(disksim2, now);
	//	}

	exit(0);
}
Beispiel #2
0
int main(int argc, char **argv) {
  int c;
  static struct option opts[] = {
    { "parv", 1, 0, 0 },    { "outv", 1, 0, 0 },
    { "model", 1, 0, 0 },
    { "mode", 1, 0, 0 },
    { "trace", 1, 0, 0 },
    {0,0,0,0}
  };

  enum optt { 
    PARV = 0,
    OUTV = 1,
    MODEL = 2,
    MODE = 3,
    TRACE = 4
  };

  struct dm_disk_if *d;
  struct dm_layout_g4 *l;

  struct trace *t;
  struct dsstuff *ds = calloc(1, sizeof(*ds));

  struct lp_block *unm;

  setlinebuf(stdout);
  FILE *outfile = NULL;
  int optind;

  char *parv = 0;
  char *outv = 0;
  char *model = 0;
  char *trace = 0;

  while((c = getopt_long(argc, argv, "q", opts, &optind)) != -1) {
    switch(c) {
    case -1:
      break;
    case 0:
      switch(optind) {
      case PARV:
	parv = strdup(optarg);
	break;
      case OUTV:
	outv = strdup(optarg);
	break;
      case MODEL:
	model = strdup(optarg);
	break;
      case MODE:
	if(!strcmp(optarg, "calib")) {
	  mode = CALIB;
	}
	else if(!strcmp(optarg, "gentrace")) {
	  mode = GENTRACE;
	}
	else {
	  fprintf(stderr, "*** bad mode %s\n", optarg);
	  exit(1);
	}
	break;

      case TRACE:
	trace = strdup(optarg);
	break;

      default:
	ddbg_assert(0);
	break;
      }
      break;
    default:
      ddbg_assert(0);
      break;
    }
  }

  t = setup_trace(trace);
  if(mode == CALIB) {
    outfile = fopen(model, "w");
    ddbg_assert(outfile);
  }

  ds->iface = disksim_interface_initialize(parv, 
					   outv,
					   cb,
					   schedule_callback,
					   deschedule_callback,
					   ds,
					   18,  // argc
					   nocache_over);

  d = disksim_getdiskmodel(ds->iface, 0);
  l = (struct dm_layout_g4 *)d->layout;

  do_idx(d, 0, l->root, l, ds, t, 0);

  extern struct lp_block* marshal_layout_g4(struct dm_layout_g4 *);

  if(mode == CALIB) {
    unm = marshal_layout_g4(l);
    unparse_block(unm, outfile);
    fclose(outfile);
  }

  free(ds);

  fclose(t->fp);
  free(t);

  return 0;
}
Beispiel #3
0
int
main(int argc, char *argv[])
{
  int i;
  int nsectors;
  struct stat buf;
  struct disksim_request r;
  struct disksim_interface *disksim;
  unsigned long pos=0;

  int measurements;
  struct stat; 
  int len = 8192000;
  int test_encapsulation;
  struct disksim_interface* iface;  
  struct gengetopt_args_info args_info; 

  double t;
  
  if (argc != 4 || (measurements = atoi(argv[3])) <= 0) {
    fprintf(stderr, "usage: %s <param file> <output file> <#measurements>\n",
	    argv[0]);
    exit(1);
  }

  if (stat(argv[1], &buf) < 0)
    panic(argv[1]);

  disksim = disksim_interface_initialize(argv[1], 
					 argv[2],
					 syssim_report_completion,
					 syssim_schedule_callback,
					 syssim_deschedule_callback,
					 0,
					 0,
					 0);

  /* NOTE: it is bad to use this internal disksim call from external... */
  DISKSIM_srand48(1);

  for (i=0; i < measurements; i++) {
    r.start = now;
    r.flags = DISKSIM_READ;
    r.devno = 0;

    /* NOTE: it is bad to use this internal disksim call from external... */
    r.blkno =  pos; //BLOCK2SECTOR*(DISKSIM_lrand48()%(nsectors/BLOCK2SECTOR));
    r.bytecount = SECTOR;
    completed = 0;

    t = now;
    disksim_interface_request_arrive(disksim, now, &r);

    /* Process events until this I/O is completed */
    while(next_event >= 0) {
      now = next_event;
      next_event = -1;
      disksim_interface_internal_event(disksim, now, 0);
    }

    pos+= SECTOR;
    fprintf(stdout, "%d %g\n",i,(now-t)*1000.0);

    if (!completed) {
      fprintf(stderr,
	      "%s: internal error. Last event not completed %d\n",
	      argv[0], i);
      exit(1);
    }
  }

  disksim_interface_shutdown(disksim, now);

  print_statistics(&st, "response time");

  exit(0);
}