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

📄 syssim_driver2.c

📁 目前最精确的磁盘模拟器的第3版
💻 C
📖 第 1 页 / 共 5 页
字号:
		if((max_bandwidth*FB_weight < temp_bandwidth && 	    max_bandwidth*max_weight < temp_bandwidth * target_weight) ||	   max_bandwidth < temp_bandwidth*FB_weight){	    max_bandwidth = temp_bandwidth;	    max_weight = target_weight;	    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_BLOCK_COIN(alg_args_t *args){  /* static vars */  static int max_count;  /* 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;  int i;  int temp_count=0;    if(args->inputflags & SCHED_INIT){    max_count = 0;  }  if(args->target_cyl < numcyls &&      free_count[args->devno][args->target_cyl] >= max_count){    seek_angles(args,		&source_seekangle,		&dest_seekangle,		&extra_angle);    if(extra_angle > 0.0 && (max_count == 0 || extra_angle			     >= sector_angle[args->best_cyl][max_count])){      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);		if(temp_count != 0){	  if(temp_count > max_count || 	     ((temp_count == max_count) && 	      ((rand() & 0x1) == 1))){	    max_count = temp_count;	    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_BLOCK(alg_args_t *args){  /* static vars */  static int max_count;  /* 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;  int i;  int temp_count=0;    if(args->inputflags & SCHED_INIT){    max_count = 0;  }    if(args->target_cyl < numcyls &&      free_count[args->devno][args->target_cyl] >= max_count){        seek_angles(args,		&source_seekangle,		&dest_seekangle,		&extra_angle);        if(extra_angle > 0.0 && (max_count == 0 ||			     extra_angle >= 			     sector_angle[args->best_cyl][max_count])){      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);		if(temp_count > max_count){	  /*	  if(args->target_cyl != args->source_cyl && args->target_cyl != args->dest_cyl){		  fprintf(stderr,"stop %d finish %d extra %d count %d\n",stop_sector,temp_finish_sector,extra_sectors,temp_count);		  fprintf(stderr,"source %d dest %d target %d time %f\n",args->source_cyl,args->dest_cyl,args->target_cyl,args->rotate_angle);		  }*/	  max_count = temp_count;	  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_SSTF(alg_args_t *args){#if 0  int i,j;  float source_seekangle;  float dest_seekangle;  float extra_angle;  int temp_finish_sector = 0.0;  unsigned int extra_sectors;  unsigned int temp_count;  unsigned int stop_sector;  int randval;  int last_found = 0;  if(args->inputflags & SCHED_INIT){  }  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);            randval = args->source_surface;      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]);	  if(temp_count > 0 && 	     !BITMAP_CHECK(args->devno,args->target_cyl,i,(stop_sector + j) % 			  sectorspercyl[args->target_cyl])){	    last_found = j + 1 + stop_sector;	    args->surface = (i+randval) % numsurfaces;	    args->start_sector = stop_sector;	    args->new_angle = args->rotate_angle - source_seekangle 	      - ((float)j/(float)sectorspercyl[args->target_cyl] * oneRotation);	    	    args->finish_sector = last_found % sectorspercyl[args->target_cyl];	    args->best_cyl = args->target_cyl;	    args->outputflags |= SCHED_OUT_VALID;	    return(1);	  }	}	if(temp_count > 0){	  last_found = j + 1 + stop_sector;	  args->surface = (i+randval) % numsurfaces;	  args->start_sector = stop_sector;	  args->new_angle = args->rotate_angle - source_seekangle 	    - ((float)j/(float)sectorspercyl[args->target_cyl] * oneRotation);	  	  args->finish_sector = last_found % sectorspercyl[args->target_cyl];	  args->best_cyl = args->target_cyl;	  args->outputflags |= SCHED_OUT_VALID;	  return(1);	  	}      }    }else{    }  }else{  }#endif  return(0);}#define INIT_SEPTF_POS 999999.0#define MAX_FAIL 50int make_selection_SEPTF(alg_args_t *args){    /* static vars */  static float max_bandwidth;  static float best_pos;  static int fail_count;  /* end static vars */  int i;  float source_seekangle;  float dest_seekangle;  float extra_angle;  float temp_bandwidth;  float temp_latency;  float temp_pos = INIT_SEPTF_POS;  int temp_finish_sector = 0.0;  unsigned int extra_sectors;  unsigned int temp_count;  unsigned int last_count;  unsigned int last_found;  unsigned int before_found;  unsigned int stop_sector;    if(args->inputflags & SCHED_INIT){    max_bandwidth = 0.0;    fail_count = 0;    best_pos = INIT_SEPTF_POS;  }  if(args->target_cyl < numcyls){    seek_angles(args,		&source_seekangle,		&dest_seekangle,		&extra_angle);    if((dest_seekangle + source_seekangle - 	seek_angle[abs(args->source_cyl-args->dest_cyl)]) > best_pos){      fail_count++;      if(fail_count > MAX_FAIL){	return(1);      }    }    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++){	temp_count = 0;		count_blocks(stop_sector,		     temp_finish_sector,		     extra_sectors,		     i,		     args,		     &temp_count,		     &before_found,		     &last_found,		     &last_count);		if(temp_count > 0){	  temp_latency = sector_angle[args->target_cyl][last_count];	  	  temp_bandwidth = sector_angle[args->target_cyl][temp_count];	  	  temp_pos = ((args->rotate_angle - extra_angle) + 		      sector_angle[args->target_cyl]		      [extra_sectors - temp_count - last_count]);	}		if(temp_count > 0 && (temp_pos < best_pos || (temp_pos == best_pos &&						      temp_bandwidth >						      max_bandwidth))){	  fail_count = 0;	  args->outputflags |= SCHED_OUT_VALID;	  best_pos = temp_pos;	  max_bandwidth = temp_bandwidth;	  args->best_cyl = args->target_cyl;	  args->surface = i;	  args->start_sector = stop_sector;	  args->new_angle = temp_latency; 	  args->finish_sector = last_found;	}      }    }else{    }  }else{  }  return(0);}int make_selection_SEPTF_FRAGMENT(alg_args_t *args){    /* static vars */  static float max_bandwidth;  static float best_pos;  static int fail_count;  /* end static vars */  int i,j;  float source_seekangle;  float dest_seekangle;  float extra_angle;  float temp_bandwidth;  float temp_latency;  float temp_pos = INIT_SEPTF_POS;  unsigned int temp_finish_sector = 0;  unsigned int extra_sectors;  unsigned int temp_count;  unsigned int last_count;  unsigned int last_found;  unsigned int before_found;  unsigned int stop_sector;  int new_finish_sector = 0;  int new_stop_sector;  int new_extra_sectors;  int done;  int stop_fragment_count=0;  int finish_fragment_count=0;    if(args->inputflags & SCHED_INIT){    max_bandwidth = 0.0;    fail_count = 0;    best_pos = INIT_SEPTF_POS;  }  if(args->target_cyl < numcyls){    seek_angles(args,		&source_seekangle,		&dest_seekangle,		&extra_angle);    if((dest_seekangle + source_seekangle - 	seek_angle[abs(args->source_cyl-args->dest_cyl)]) > best_pos){      fail_count++;      if(fail_count > MAX_FAIL){	return(1);      }    }    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++){	temp_count = 0;	new_extra_sectors = extra_sectors;	new_stop_sector = stop_sector;	new_finish_sector = temp_finish_sector;	if(extra_sectors != sectorspercyl[i]){	  new_stop_sector = stop_sector - min_fragment_size;	  while(new_stop_sector < 0){	    new_stop_sector += sectorspercyl[i];	  }	  done = 0;	  stop_fragment_count = 0;	  if(new_stop_sector > stop_sector){	    for(j=new_stop_sector;j<sectorspercyl[i] && done != 1;j++){	      if(BITMAP_CHECK(args->devno,args->target_cyl,i,j)){		done = 1;	      }else{		stop_fragment_count++;	      }	    }	    for(j=0;j<stop_sector && done != 1;j++){	      if(BITMAP_CHECK(args->devno,args->target_cyl,i,j)){		done = 1;	      }else{		stop_fragment_count++;	      }	    }	  }else{	    for(j=new_stop_sector;j<stop_sector && done != 1;j++){	      if(BITMAP_CHECK(args->devno,args->target_cyl,i,j)){		done = 1;	      }else{		stop_fragment_count++;	      }	    }	  }	  if(stop_fragment_count != min_fragment_size){	    new_stop_sector = stop_sector + stop_fragment_count;	    while(new_stop_sector >= sectorspercyl[i]){	      new_stop_sector -= sectorspercyl[i];	    }	    new_extra_sectors -= stop_fragment_count;	  }else{	    new_stop_sector = stop_sector;	  }	    	  done = 0;	  finish_fragment_count = 0;	  new_finish_sector = temp_finish_sector + min_fragment_size;	  while(new_finish_sector >= sectorspercyl[i]){	    new_finish_sector -= sectorspercyl[i];	  }	  if(new_finish_sector < temp_finish_sector){	    for(j=new_finish_sector;j>0 && done != 1;j--){	      if(BITMAP_CHECK(args->devno,args->target_cyl,i,(j-1))){		done = 1;	      }else{		finish_fragment_count++;	      }	    }	    for(j=sectorspercyl[i];j>temp_finish_sector && done != 1;j--){	      if(BITMAP_CHECK(args->devno,args->target_cyl,i,(j-1))){		done = 1;	      }else{		finish_fragment_count++;	      }	    }	  }else{	    for(j=new_finish_sector;j>temp_finish_sector && done != 1;j--){	      if(BITMAP_CHECK(args->devno,args->target_cyl,i,(j-1))){		done = 1;	      }else{		finish_fragment_count++;	      }	    }	  }	  if(finish_fragment_count != min_fragment_size){	    new_finish_sector = temp_finish_sector - finish_fragment_count;	    while(new_finish_sector < 0){	      new_finish_sector += sectorspercyl[i];	    }	    new_extra_sectors -= finish_fragment_count;	  }else{	    new_finish_sector = temp_finish_sector;	  }	  if(new_extra_sectors < 0){	    new_extra_sectors = 0;	  }	}		/*	if(new_stop_sector != stop_sector || (new_finish_sector != 		temp_finish_sector)){		fprintf(stderr,"stop %d new_stop %d finish %d new_finish %d extra %d new_extra %d\n",stop_sector,new_stop_sector,temp_finish_sector,new_finish_sector,extra_sectors,new_extra_sectors);		}else{		fprintf(stderr,"BLAH\n");		}*/	count_blocks(new_stop_sector,		     new_finish_sector,		     new_extra_sectors,		     i,		     args,		     &temp_count,		     &before_found,		     &last_found,		     &last_count);		if(temp_count > 0){	  temp_latency = sector_angle[args->target_cyl][last_count + 						       finish_fragment_count];	  	  temp_bandwidth = sector_angle[args->target_cyl][temp_count];	  	  temp_pos = ((args->rota

⌨️ 快捷键说明

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