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

📄 syssim_driver2.c

📁 目前最精确的磁盘模拟器的第3版
💻 C
📖 第 1 页 / 共 5 页
字号:
	  max_bandwidth = temp_bandwidth;	  args->outputflags |= SCHED_OUT_VALID;	  args->best_cyl = args->target_cyl;	  args->surface = i;	  args->new_angle = 0;	  	  args->start_sector = stop_sector;	  args->finish_sector = temp_finish_sector;	}	if((args->target_cyl >= (numcyls-CYL_RANGE)) || 	   (args->target_cyl <= CYL_RANGE)){	  if(temp_max < temp_bandwidth){	    temp_max = temp_bandwidth;	    temp_surface = i;	  }	}      }    }  }  if((args->target_cyl >= (numcyls-CYL_RANGE)) ||      (args->target_cyl <= CYL_RANGE)){    if(temp_bandwidth != 0.0){      args->outputflags |= SCHED_OUT_VALID;      args->best_cyl = args->target_cyl;      args->surface = temp_surface;      args->new_angle = 0;            args->start_sector = stop_sector;      args->finish_sector = temp_finish_sector;      return(1);    }  }  return(0);}int make_selection_GREEDY_BW_COIN(alg_args_t *args){  /* static vars */  static float max_bandwidth;  /* end static vars */  float extra_angle = 0.0;  float source_seekangle = 0.0;  float dest_seekangle = 0.0;  float temp_bandwidth = 0.0;  unsigned int extra_sectors = 0;  int temp_finish_sector = 0;  unsigned int stop_sector = 0;  int i;  int temp_count=0;    if(args->inputflags & SCHED_INIT){    max_bandwidth = 0.0;  }    if(args->target_cyl < numcyls && (max_bandwidth == 0.0 ||				    (free_count[args->devno][args->target_cyl]				     >= sectorspercyl[args->target_cyl] ||				     sector_angle[args->target_cyl]				     [free_count[args->devno]				     [args->target_cyl]] >= 				     max_bandwidth))){        seek_angles(args,		&source_seekangle,		&dest_seekangle,		&extra_angle);        if(extra_angle > 0.0 && (max_bandwidth == 0.0 || extra_angle			     >= max_bandwidth)){            location_info(extra_angle,		    source_seekangle,		    args,		    &stop_sector,		    &temp_finish_sector,		    &extra_sectors);            for(i=0;i<numsurfaces;i++){		count_blocks(stop_sector,		     temp_finish_sector,		     extra_sectors,		     i,		     args,		     &temp_count,		     NULL,		     NULL,		     NULL);		temp_bandwidth = sector_angle[args->target_cyl][temp_count];		if(temp_count != 0){	  if(temp_bandwidth > max_bandwidth || 	     ((temp_bandwidth == max_bandwidth) && 	      ((rand() & 0x1) == 1))){	    max_bandwidth = temp_bandwidth;	    args->outputflags |= SCHED_OUT_VALID;	    args->best_cyl = args->target_cyl;	    args->surface = i;	    args->new_angle = 0;	    	    args->start_sector = stop_sector;	    args->finish_sector = temp_finish_sector;	  }	}      }    }  }  return(0);}int make_selection_GREEDY_BW(alg_args_t *args){  /* static vars */  static float max_bandwidth;  /* end static vars */    float extra_angle = 0.0;  float source_seekangle = 0.0;  float dest_seekangle = 0.0;  float temp_bandwidth = 0.0;  unsigned int extra_sectors = 0;  int temp_finish_sector = 0;  unsigned int stop_sector = 0;  int i;  int temp_count=0;    if(args->inputflags & SCHED_INIT){    max_bandwidth = 0.0;  }    if(args->target_cyl < numcyls && (max_bandwidth == 0.0 ||				    (free_count[args->devno][args->target_cyl]				     >= sectorspercyl[args->target_cyl] ||				     sector_angle[args->target_cyl]				     [free_count[args->devno]				     [args->target_cyl]] >= 				     max_bandwidth))){        seek_angles(args,		&source_seekangle,		&dest_seekangle,		&extra_angle);        if(extra_angle > 0.0 && (max_bandwidth == 0.0 || extra_angle			     >= max_bandwidth)){            location_info(extra_angle,		    source_seekangle,		    args,		    &stop_sector,		    &temp_finish_sector,		    &extra_sectors);            for(i=0;i<numsurfaces;i++){		count_blocks(stop_sector,		     temp_finish_sector,		     extra_sectors,		     i,		     args,		     &temp_count,		     NULL,		     NULL,		     NULL);		temp_bandwidth = sector_angle[args->target_cyl][temp_count];		if(temp_bandwidth > max_bandwidth){	  max_bandwidth = temp_bandwidth;	  args->outputflags |= SCHED_OUT_VALID;	  args->best_cyl = args->target_cyl;	  args->surface = i;	  args->new_angle = 0;	  	  args->start_sector = stop_sector;	  args->finish_sector = temp_finish_sector;	}      }    }  }  return(0);}int make_selection_GREEDY_AREA_FIRST(alg_args_t *args){  /* static vars */  static float max_bandwidth;  /* end static vars */    float extra_angle = 0.0;  float source_seekangle = 0.0;  float dest_seekangle = 0.0;  float temp_bandwidth = 0.0;  unsigned int extra_sectors = 0;  int temp_finish_sector = 0;  unsigned int stop_sector = 0;  int i;  int temp_count=0;    if(args->inputflags & SCHED_INIT){    max_bandwidth = 0.0;  }    if (((args->target_cyl >= area_firstcyl) &&        (args->target_cyl <= area_lastcyl))      && (args->target_cyl < numcyls)){        seek_angles(args,		&source_seekangle,		&dest_seekangle,		&extra_angle);        if(extra_angle > 0.0) {            location_info(extra_angle,		    source_seekangle,		    args,		    &stop_sector,		    &temp_finish_sector,		    &extra_sectors);      for(i=0;i<numsurfaces;i++){		count_blocks(stop_sector,		     temp_finish_sector,		     extra_sectors,		     i,		     args,		     &temp_count,		     NULL,		     NULL,		     NULL);		temp_bandwidth = sector_angle[args->target_cyl][temp_count];		if (temp_bandwidth > max_bandwidth) {	  max_bandwidth = temp_bandwidth;	  args->outputflags |= SCHED_OUT_VALID;	  args->best_cyl = args->target_cyl;	  args->surface = i;	  args->new_angle = 0;	  	  args->start_sector = stop_sector;	  args->finish_sector = temp_finish_sector;	}      }    }  }  return(0);}int make_selection_GREEDY_UNIFORM_RATE(alg_args_t *args){  /* static vars */  static float max_bandwidth;  /* end static vars */  float extra_angle = 0.0;  float source_seekangle = 0.0;  float dest_seekangle = 0.0;  float temp_bandwidth = 0.0;  unsigned int extra_sectors = 0;  int temp_finish_sector = 0;  unsigned int stop_sector = 0;  int i = 0;    if(args->inputflags & SCHED_INIT){    max_bandwidth = 0.0;  }  if(args->target_cyl < numcyls) {         seek_angles(args,		&source_seekangle,		&dest_seekangle,		&extra_angle);    if(extra_angle > 0.0) {              location_info(extra_angle,		    source_seekangle,		    args,		    &stop_sector,		    &temp_finish_sector,		    &extra_sectors);            temp_bandwidth = ((float) free_count[args->devno][args->target_cyl]/			(float) sectorspercyl[args->target_cyl]);       if (temp_bandwidth >= max_bandwidth) {      max_bandwidth = temp_bandwidth;      args->outputflags |= SCHED_OUT_VALID;      args->best_cyl = args->target_cyl;      args->surface = i;      args->new_angle = 0;            args->start_sector = stop_sector;      args->finish_sector = temp_finish_sector;      }    }  }  return(0);}int make_selection_GREEDY_BW_SOURCE(alg_args_t *args){  /* static vars */  static float max_bandwidth;  /* end static vars */  float extra_angle = 0.0;  float source_seekangle = 0.0;  float dest_seekangle = 0.0;  float temp_bandwidth = 0.0;  unsigned int extra_sectors = 0;  int temp_finish_sector = 0.0;  unsigned int stop_sector = 0;  int i;  int temp_count=0;    if(args->inputflags & SCHED_INIT){    max_bandwidth = 0.0;  }  if(args->target_cyl < numcyls && (max_bandwidth == 0.0 ||				    (free_count[args->devno][args->target_cyl]				     >= sectorspercyl[args->target_cyl] ||				     sector_angle[args->target_cyl]				     [free_count[args->devno]				     [args->target_cyl]] >= 				     max_bandwidth))){    seek_angles(args,		&source_seekangle,		&dest_seekangle,		&extra_angle);    if(extra_angle > 0.0 && (max_bandwidth == 0.0 || extra_angle       >= max_bandwidth)){      location_info(extra_angle,		    source_seekangle,		    args,		    &stop_sector,		    &temp_finish_sector,		    &extra_sectors);      for(i=0;i<numsurfaces;i++){	count_blocks(stop_sector,		     temp_finish_sector,		     extra_sectors,		     i,		     args,		     &temp_count,		     NULL,		     NULL,		     NULL);		temp_bandwidth = sector_angle[args->target_cyl][temp_count];	if(temp_bandwidth > max_bandwidth || 	   ((temp_bandwidth == max_bandwidth) && (temp_count != 0) && 	    (abs(args->target_cyl-args->source_cyl) < 	     abs(args->best_cyl-args->source_cyl)))){	  max_bandwidth = temp_bandwidth;	  args->outputflags |= SCHED_OUT_VALID;	  args->best_cyl = args->target_cyl;	  args->surface = i;	  args->new_angle = 0;	  	  args->start_sector = stop_sector;	  args->finish_sector = temp_finish_sector;	}      }    }  }  return(0);}#define MAX_CYL_DIST 150int make_selection_GREEDY_BW_SOURCE_DIST(alg_args_t *args){  /* static vars */  static float max_bandwidth;  /* end static vars */  float extra_angle = 0.0;  float source_seekangle = 0.0;  float dest_seekangle = 0.0;  float temp_bandwidth = 0.0;  float temp_latency = 0.0;  unsigned int extra_sectors = 0;  int temp_finish_sector = 0;  unsigned int stop_sector = 0;  int i;  int temp_count=0;  int last_found=0;  int last_count=0;    if(args->inputflags & SCHED_INIT){    max_bandwidth = 0.0;  }    if(abs(args->target_cyl - args->source_cyl) > MAX_CYL_DIST &&      abs(args->target_cyl - args->dest_cyl) > MAX_CYL_DIST &&      args->outputflags & SCHED_OUT_VALID){    return(1);  }  if(args->target_cyl < numcyls && (max_bandwidth == 0.0 ||  (free_count[args->devno][args->target_cyl]				     >= sectorspercyl[args->target_cyl] ||				     sector_angle[args->target_cyl]				     [free_count[args->devno]				     [args->target_cyl]] >= 				     max_bandwidth))){        seek_angles(args,		&source_seekangle,		&dest_seekangle,		&extra_angle);        if(extra_angle > 0.0 && (max_bandwidth == 0.0 || extra_angle			     >= max_bandwidth)){      location_info(extra_angle,		    source_seekangle,		    args,		    &stop_sector,		    &temp_finish_sector,		    &extra_sectors);            for(i=0;i<numsurfaces;i++){		count_blocks(stop_sector,		     temp_finish_sector,		     extra_sectors,		     i,		     args,		     &temp_count,		     NULL,		     &last_found,		     &last_count);		temp_bandwidth = sector_angle[args->target_cyl][temp_count];		temp_latency = sector_angle[args->target_cyl][last_count];		if(temp_count != 0){	  if(temp_bandwidth > max_bandwidth || 	     ((temp_bandwidth == max_bandwidth) && 	      (abs(args->target_cyl-args->source_cyl) < 	       abs(args->best_cyl-args->source_cyl)))){	    max_bandwidth = temp_bandwidth;	    args->outputflags |= SCHED_OUT_VALID;	    args->best_cyl = args->target_cyl;	    args->surface = i;	    args->new_angle = temp_latency;	    	    args->start_sector = stop_sector;	    args->finish_sector = last_found;	  }	}      }    }  }  return(0);}int make_selection_GREEDY_BW_TIME_DIST(alg_args_t *args){  /* static vars */  static float max_bandwidth;  static float max_latency;  /* end static vars */  float extra_angle = 0.0;  float source_seekangle = 0.0;  float dest_seekangle = 0.0;  unsigned int extra_sectors = 0;  int temp_finish_sector = 0;  float temp_latency = 0.0;  float temp_bandwidth = 0.0;  unsigned int stop_sector = 0;  int i;  int temp_count=0;  int last_found=0;  int last_count=0;    if(args->inputflags & SCHED_INIT){    max_bandwidth = 0.0;    max_latency = 0.0;  }    if(abs(args->target_cyl - args->source_cyl) > MAX_CYL_DIST &&      abs(args->target_cyl - args->dest_cyl) > MAX_CYL_DIST &&      args->outputflags & SCHED_OUT_VALID){    return(1);  }  if(args->target_cyl < numcyls && (max_bandwidth == 0.0 ||				    (free_count[args->devno][args->target_cyl]				     >= sectorspercyl[args->target_cyl] ||				     sector_angle[args->target_cyl]				     [free_count[args->devno]				     [args->target_cyl]] >= 				     max_bandwidth))){    seek_angles(args,		&source_seekangle,		&dest_seekangle,		&extra_angle);    if(extra_angle > 0.0 && (max_bandwidth == 0.0 || extra_angle			     >= max_bandwidth)){      location_info(extra_angle,		    source_seekangle,		    args,		    &stop_sector,		    &temp_finish_sector,		    &extra_sectors);

⌨️ 快捷键说明

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