📄 disksim_ioqueue.c
字号:
test->time = simtime + delay; if (ageweight) { tmp = temp->iolist; age = tmp->time; while (tmp) { if (tmp->time < age) { age = tmp->time; } tmp = tmp->next; } age = simtime - age; } if ((ageweight == 2) || ((ageweight == 3) && (test->flags & (TIME_CRITICAL | TIME_LIMITED)))) { delay -= age * weight * (double) 0.001; } if (delay < mintime) { if (posonly) { temp_delay = device_get_servtime(test->devno, test, checkcache, (mintime - delay)); temp_seek = device_get_seektime(test->devno, test, checkcache, (mintime - delay)); delay += temp_delay; } else { delay += device_get_acctime(test->devno, test, (mintime - delay)); } if (ageweight == 1) { delay *= (weight - age) / weight; } if((temp_delay - temp_seek) < 0.0) fprintf(stderr,"Oops delay negative %f\n",temp_delay-temp_seek); if ((delay - (temp_delay - temp_seek) * queue->bigqueue->latency_weight) < (mintime - minsubtract)) { best = temp; mintime = delay; minsubtract = (temp_delay - temp_seek) * queue->bigqueue->latency_weight; } } } temp = temp->next; } addtoextraq((event *) test); /* fprintf (outputfile, "Selected request: %f, cylno %d, blkno %d, read %d, devno %d\n", mintime, best->cylinder, best->blkno, (best->flags & READ), best->iolist->devno); */ return(best);}static iobuf *ioqueue_get_request_from_opt_sptf_weight_queue (subqueue *queue, int checkcache, int ageweight, int posonly){ int i; iobuf *temp; ioreq_event *test; double readdelay; double writedelay; double weight; ioreq_event *tmp; iobuf *best = NULL; iobuf *best2 = NULL; double mintime = 100000.0; double temp_mintime = 100000.0; double maxrot = 0.0; double delay = 0.0; double age = 0.0; double temp_delay = 0.0; double temp_seek = 0.0; ASSERT((ageweight >= 0) && (ageweight <= 3)); readdelay = queue->bigqueue->readdelay; writedelay = queue->bigqueue->writedelay; weight = (double) queue->bigqueue->to_time; test = (ioreq_event *) getfromextraq(); temp = queue->list->next; for (i=0; i<queue->listlen; i++) { if (READY_TO_GO(temp,queue) && (ioqueue_seqstream_head(queue->bigqueue, queue->list->next, temp))) { test->blkno = temp->blkno; test->bcount = temp->totalsize; test->devno = temp->iolist->devno; test->flags = temp->flags; delay = (temp->flags & READ) ? readdelay : writedelay; test->time = simtime + delay; if (ageweight) { tmp = temp->iolist; age = tmp->time; while (tmp) { if (tmp->time < age) { age = tmp->time; } tmp = tmp->next; } age = simtime - age; } if ((ageweight == 2) || ((ageweight == 3) && (test->flags & (TIME_CRITICAL | TIME_LIMITED)))) { delay -= age * weight * (double) 0.001; } if (delay < mintime) { if (posonly) { temp_delay = device_get_servtime(test->devno, test, checkcache, (mintime - delay)); delay += temp_delay; } else { delay += device_get_acctime(test->devno, test, (mintime - delay)); } if (ageweight == 1) { delay *= (weight - age) / weight; } if (delay < temp_mintime) { temp_mintime = delay; best2 = temp; } } } temp = temp->next; } addtoextraq((event *) test); readdelay = queue->bigqueue->readdelay; writedelay = queue->bigqueue->writedelay; weight = (double) queue->bigqueue->to_time; test = (ioreq_event *) getfromextraq(); temp = queue->list->next; for (i=0; i<queue->listlen; i++) { if (READY_TO_GO(temp,queue) && (ioqueue_seqstream_head(queue->bigqueue, queue->list->next, temp))) { test->blkno = temp->blkno; test->bcount = temp->totalsize; test->devno = temp->iolist->devno; test->flags = temp->flags; delay = (temp->flags & READ) ? readdelay : writedelay; test->time = simtime + delay; if (ageweight) { tmp = temp->iolist; age = tmp->time; while (tmp) { if (tmp->time < age) { age = tmp->time; } tmp = tmp->next; } age = simtime - age; } if ((ageweight == 2) || ((ageweight == 3) && (test->flags & (TIME_CRITICAL | TIME_LIMITED)))) { delay -= age * weight * (double) 0.001; } if (delay < mintime) { if (posonly) { temp_delay = device_get_servtime(test->devno, test, checkcache, (mintime - delay)); temp_seek = device_get_seektime(test->devno, test, checkcache, (mintime - delay)); delay += temp_delay; } else { delay += device_get_acctime(test->devno, test, (mintime - delay)); } if (ageweight == 1) { delay *= (weight - age) / weight; } /* fprintf(outputfile, "get_request_from_sptf...:: delay = %f\n", delay); */ if((temp_delay - temp_seek) < 0.0) fprintf(stderr,"Oops delay negative %f\n",temp_delay-temp_seek); if (delay <= (temp_mintime * (1+queue->bigqueue->latency_weight))) { if((temp_delay - temp_seek) >= maxrot){ best = temp; maxrot = temp_delay - temp_seek; } } } } temp = temp->next; } addtoextraq((event *) test); /* fprintf (outputfile, "Selected request: %f, cylno %d, blkno %d, read %d, devno %d\n", mintime, best->cylinder, best->blkno, (best->flags & READ), best->iolist->devno); */ return(best);}static iobuf *ioqueue_get_request_from_opt_sptf_seek_weight_queue (subqueue *queue, int checkcache, int ageweight, int posonly){ int i; iobuf *temp; iobuf *best = NULL; iobuf *best2 = NULL; ioreq_event *test; double mintime = 100000.0; double temp_mintime = 100000.0; double minseek = 100000.0; double readdelay; double writedelay; double delay = 0.0; double age = 0.0; double weight; double temp_delay = 0.0; double temp_seek = 0.0; ioreq_event *tmp; ASSERT((ageweight >= 0) && (ageweight <= 3)); readdelay = queue->bigqueue->readdelay; writedelay = queue->bigqueue->writedelay; weight = (double) queue->bigqueue->to_time; test = (ioreq_event *) getfromextraq(); temp = queue->list->next; for (i=0; i<queue->listlen; i++) { if (READY_TO_GO(temp,queue) && (ioqueue_seqstream_head(queue->bigqueue, queue->list->next, temp))) { test->blkno = temp->blkno; test->bcount = temp->totalsize; test->devno = temp->iolist->devno; test->flags = temp->flags; delay = (temp->flags & READ) ? readdelay : writedelay; test->time = simtime + delay; if (ageweight) { tmp = temp->iolist; age = tmp->time; while (tmp) { if (tmp->time < age) { age = tmp->time; } tmp = tmp->next; } age = simtime - age; } if ((ageweight == 2) || ((ageweight == 3) && (test->flags & (TIME_CRITICAL | TIME_LIMITED)))) { delay -= age * weight * (double) 0.001; } if (delay < mintime) { if (posonly) { temp_delay = device_get_servtime(test->devno, test, checkcache, (mintime - delay)); temp_seek = device_get_seektime(test->devno, test, checkcache, (mintime - delay)); delay += temp_delay; } else { delay += device_get_acctime(test->devno, test, (mintime - delay)); } if (ageweight == 1) { delay *= (weight - age) / weight; } /* fprintf(outputfile, "get_request_from_sptf...:: delay = %f\n", delay); */ if (delay < temp_mintime) { temp_mintime = delay; best2 = temp; } if (delay <= (temp_mintime * (1+queue->bigqueue->latency_weight))) { if(temp_seek < minseek){ best = temp; minseek = temp_seek; } } } } temp = temp->next; } addtoextraq((event *) test);#if 0 for (i=0; i<queue->listlen; i++) { if (READY_TO_GO(temp,queue) && (ioqueue_seqstream_head(queue->bigqueue, queue->list->next, temp))) { test->blkno = temp->blkno; test->bcount = temp->totalsize; test->devno = temp->iolist->devno; test->flags = temp->flags; delay = (temp->flags & READ) ? readdelay : writedelay; test->time = simtime + delay; if (ageweight) { tmp = temp->iolist; age = tmp->time; while (tmp) { if (tmp->time < age) { age = tmp->time; } tmp = tmp->next; } age = simtime - age; } if ((ageweight == 2) || ((ageweight == 3) && (test->flags & (TIME_CRITICAL | TIME_LIMITED)))) { delay -= age * weight * (double) 0.001; } if (delay < mintime) { if (posonly) { temp_delay = device_get_servtime(test->devno, test, checkcache, (mintime - delay)); //fprintf(outputfile, "temp_delay = %f\n",temp_delay); delay += temp_delay; } else { delay += device_get_acctime(test->devno, test, (mintime - delay)); } if (ageweight == 1) { delay *= (weight - age) / weight; } /* fprintf(outputfile, "get_request_from_sptf...:: delay = %f\n", delay); */ if (delay < temp_mintime) { temp_mintime = delay; best2 = temp; } } } temp = temp->next; } addtoextraq((event *) test); readdelay = queue->bigqueue->readdelay; writedelay = queue->bigqueue->writedelay; weight = (double) queue->bigqueue->to_time; test = (ioreq_event *) getfromextraq(); temp = queue->list->next; for (i=0; i<queue->listlen; i++) { if (READY_TO_GO(temp,queue) && (ioqueue_seqstream_head(queue->bigqueue, queue->list->next, temp))) { test->blkno = temp->blkno; test->bcount = temp->totalsize; test->devno = temp->iolist->devno; test->flags = temp->flags; delay = (temp->flags & READ) ? readdelay : writedelay; test->time = simtime + delay; if (ageweight) { tmp = temp->iolist; age = tmp->time; while (tmp) { if (tmp->time < age) { age = tmp->time; } tmp = tmp->next; } age = simtime - age; } if ((ageweight == 2) || ((ageweight == 3) && (test->flags & (TIME_CRITICAL | TIME_LIMITED)))) { delay -= age * weight * (double) 0.001; } if (delay < mintime) { if (posonly) { temp_delay = device_get_servtime(test->devno, test, checkcache, (mintime - delay)); temp_seek = device_get_seektime(test->devno, test, checkcache, (mintime - delay)); //fprintf(outputfile, "temp_delay = %f\n",temp_delay); delay += temp_delay; } else { delay += device_get_acctime(test->devno, test, (mintime - delay)); } if (ageweight == 1) { delay *= (weight - age) / weight; } /* fprintf(outputfile, "get_request_from_sptf...:: delay = %f\n", delay); */ if(temp_seek < 0.0) fprintf(stderr,"Oops delay negative %f\n",temp_delay-temp_seek); if (delay <= (temp_mintime * (1+queue->bigqueue->latency_weight))) { if(temp_seek < minseek){ best = temp; minseek = temp_seek; } } } } temp = temp->next; } addtoextraq((event *) test);#endif /* fprintf (outputfile, "Selected request: %f, cylno %d, blkno %d, read %d, devno %d\n", mintime, best->cylinder, best->blkno, (best->flags & READ), best->iolist->devno); */ return(best);}/* * * ioqueue_get_request_from_sdf_queue() * * subqueue queue - the queue * int exact - a flag to device_get_distance: if FALSE, then calculate from the last lbn requested, * if TRUE, calculate from current device position * int direction - a flag to device_get_distance: if FALSE, don't take distance into account * if TRUE, return an "equivalent distance" taking into account the current direction * of the moving sled/disk arm * * returns the request with the shortest distance from the current position * */ static iobuf *ioqueue_get_request_from_sdf_queue (subqueue *queue, int exact, int direction) { int i; iobuf *temp; iobuf *best = NULL; ioreq_event *test; int distance; int min_distance = 1000000; /* fprintf(outputfile, "ioqueue_get_request_from_sdf_queue:: exact = %d, direction = %d\n", exact, direction); */ test = (ioreq_event *) getfromextraq(); temp = queue->list->next; for (i=0; i<queue->listlen; i++) { if (READY_TO_GO(temp,queue) && (ioqueue_seqstream_head(queue->bigqueue, queue->list->next, temp))) { test->blkno = temp->blkno; test->bcount = temp->totalsize; test->devno = temp->iolist->devno; test->flags = temp->flags; if (exact) { distance = device_get_distance(test->devno, test, -1, direction); } else { distance = device_get_distance(test->devno, test, queue->lastblkno, direction); } /* fprintf(outputfile, "get_from_sdf_queue:: blkno = %d, distance = %d\n", test->blkno, distance); */ if (distance < min_distance) { b
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -