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

📄 syssim_driver2.c

📁 目前最精确的磁盘模拟器的第3版
💻 C
📖 第 1 页 / 共 5 页
字号:
      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 && (			       temp_bandwidth*FB_weight > 			       max_bandwidth ||			       (!(max_bandwidth*FB_weight > 				  temp_bandwidth) &&				temp_latency > max_latency))){	  max_bandwidth = temp_bandwidth;	  max_latency = temp_latency;	  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_TRACK(alg_args_t *args){  /* static vars */  static float max_bandwidth;  static float max_latency;  static int max_track;  /* 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 temp_track=0;  int last_found=0;  int last_count=0;    if(args->inputflags & SCHED_INIT){    max_bandwidth = 0.0;    max_latency = 0.0;    max_track = 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 ||				    sector_angle[args->target_cyl]				    [free_count[args->devno]				    [args->target_cyl]] >=				    max_bandwidth*FB_weight)){    seek_angles(args,		&source_seekangle,		&dest_seekangle,		&extra_angle);    if(extra_angle > 0.0 && extra_angle >= max_bandwidth*FB_weight){      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((free_count_track[args->devno][args->target_cyl][i] - 	    temp_count) == 0){	  temp_track = 1;	}else{	  temp_track = 0;	}	if((temp_bandwidth > max_bandwidth && temp_track == max_track) ||	   (max_bandwidth < temp_bandwidth*FB_weight && temp_track == 0 &&	    max_track == 1) ||	   (max_bandwidth*FB_weight < temp_bandwidth && temp_track == 1 &&	    max_track == 0)){	  max_bandwidth = temp_bandwidth;	  max_latency = temp_latency;	  max_track = temp_track;	  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_TRACK_DIST(alg_args_t *args){  /* static vars */  static float max_bandwidth;  static float max_latency;  static int max_track;  /* 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 temp_track=0;  int last_found=0;  int last_count=0;    if(args->inputflags & SCHED_INIT){    max_bandwidth = 0.0;    max_latency = 0.0;    max_track = 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 ||				    sector_angle[args->target_cyl]				    [free_count[args->devno]				    [args->target_cyl]] >=				    max_bandwidth*FB_weight)){    seek_angles(args,		&source_seekangle,		&dest_seekangle,		&extra_angle);    if(extra_angle > 0.0 && extra_angle >= max_bandwidth*FB_weight){      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(free_count_track[args->devno][args->target_cyl][i] - 	   temp_count == 0){	  temp_track = 1;	}else{	  temp_track = 0;	}	if((temp_bandwidth > max_bandwidth && temp_track == max_track) ||	   (max_bandwidth < temp_bandwidth*FB_weight && temp_track == 0 &&	    max_track == 1) ||	    (max_bandwidth*FB_weight < temp_bandwidth && temp_track == 1 &&	     max_track == 0)){	  max_bandwidth = temp_bandwidth;	  max_latency = temp_latency;	  max_track = temp_track;	  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_MAX_DEST(alg_args_t *args){  /* static vars */  static int 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_count != 0){	  if(temp_bandwidth > max_bandwidth || 	     ((temp_bandwidth == max_bandwidth) && 	      (abs(args->target_cyl-args->dest_cyl) > abs(args->best_cyl-args->dest_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);}int make_selection_GREEDY_BW_SOURCE_WEIGHT(alg_args_t *args){  /* static vars */  static int max_bandwidth;  static int printed = 0;  /* 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,j;  int temp_count=0;  if (!printed) {    fprintf(stderr,"The weight for algorithm %d is %f\n",	    GREEDY_BW_SOURCE_WEIGHT_ALG,FB_weight);    printed = 1;  }    if(args->inputflags & SCHED_INIT){    max_bandwidth = 0.0;  }  if(args->target_cyl < numcyls && (max_bandwidth == 0.0 || 			      (float)free_count[args->devno][args->target_cyl]/			      (float)sectorspercyl[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/oneRotation)			     >= max_bandwidth)){      location_info(extra_angle,		    source_seekangle,		    args,		    &stop_sector,		    &temp_finish_sector,		    &extra_sectors);      for(i=0;i<numsurfaces;i++){	temp_count = 0;	for(j=0;j<extra_sectors;j++){	  temp_count += BITMAP_CHECK(args->devno,args->target_cyl,i,(stop_sector + j) % 				     sectorspercyl[args->target_cyl]);	}	temp_bandwidth = (float)((float)(temp_count)/				 (float)(sectorspercyl[args->target_cyl]));	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 = 0;	    	    args->start_sector = stop_sector;	    args->finish_sector = temp_finish_sector;	  }	}      }    }  }  return(0);}int make_selection_LEAST_LATENCY(alg_args_t *args){  /* static vars */  static double latency;  static float max_bandwidth;  /* 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;  unsigned int stop_sector = 0;  double temp_latency=0.0;  float temp_bandwidth=0.0;  int i;  int temp_count=0;  int last_found=0;  int last_count=0;    if(args->inputflags & SCHED_INIT){    latency = oneRotation * oneRotation;    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);      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_latency = sector_angle[args->target_cyl][extra_sectors - 						     temp_count];	temp_bandwidth = sector_angle[args->target_cyl][temp_count];	if(temp_count > 0 && 	   (latency > temp_latency || 	    (abs(latency - temp_latency) <= 0.01 &&	     (temp_bandwidth > max_bandwidth)))){	  latency = temp_latency;	  max_bandwidth = temp_bandwidth;	  args->outputflags |= SCHED_OUT_VALID;	  args->best_cyl = args->target_cyl;	  args->surface = i;	  args->new_angle = sector_angle[args->target_cyl][last_count];	  	  args->start_sector = stop_sector;	  args->finish_sector = last_found;	}      }    }  }  return(0);}int make_selection_GREEDY_BW_PROB_COIN(alg_args_t *args){  /* static vars */  static float max_bandwidth;  static float max_weight;  /* 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;  float target_weight=0.0;    if(args->inputflags & SCHED_INIT){    max_bandwidth = 0.0;    max_weight = 0.0;  }  if(args->target_cyl < numcyls){    target_weight = probpercyl[args->target_cyl];    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];

⌨️ 快捷键说明

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