📄 disksim_iodriver.c
字号:
/* * DiskSim Storage Subsystem Simulation Environment (Version 3.0) * Revision Authors: John Bucy, Greg Ganger * Contributors: John Griffin, Jiri Schindler, Steve Schlosser * * Copyright (c) of Carnegie Mellon University, 2001, 2002, 2003. * * This software is being provided by the copyright holders under the * following license. By obtaining, using and/or copying this software, * you agree that you have read, understood, and will comply with the * following terms and conditions: * * Permission to reproduce, use, and prepare derivative works of this * software is granted provided the copyright and "No Warranty" statements * are included with all reproductions and derivative works and associated * documentation. This software may also be redistributed without charge * provided that the copyright and "No Warranty" statements are included * in all redistributions. * * NO WARRANTY. THIS SOFTWARE IS FURNISHED ON AN "AS IS" BASIS. * CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER * EXPRESSED OR IMPLIED AS TO THE MATTER INCLUDING, BUT NOT LIMITED * TO: WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY, EXCLUSIVITY * OF RESULTS OR RESULTS OBTAINED FROM USE OF THIS SOFTWARE. CARNEGIE * MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF ANY KIND WITH RESPECT * TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. * COPYRIGHT HOLDERS WILL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE * OR DOCUMENTATION. * *//* * DiskSim Storage Subsystem Simulation Environment (Version 2.0) * Revision Authors: Greg Ganger * Contributors: Ross Cohen, John Griffin, Steve Schlosser * * Copyright (c) of Carnegie Mellon University, 1999. * * Permission to reproduce, use, and prepare derivative works of * this software for internal use is granted provided the copyright * and "No Warranty" statements are included with all reproductions * and derivative works. This software may also be redistributed * without charge provided that the copyright and "No Warranty" * statements are included in all redistributions. * * NO WARRANTY. THIS SOFTWARE IS FURNISHED ON AN "AS IS" BASIS. * CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER * EXPRESSED OR IMPLIED AS TO THE MATTER INCLUDING, BUT NOT LIMITED * TO: WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY, EXCLUSIVITY * OF RESULTS OR RESULTS OBTAINED FROM USE OF THIS SOFTWARE. CARNEGIE * MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF ANY KIND WITH RESPECT * TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. *//* * DiskSim Storage Subsystem Simulation Environment * Authors: Greg Ganger, Bruce Worthington, Yale Patt * * Copyright (C) 1993, 1995, 1997 The Regents of the University of Michigan * * This software is being provided by the copyright holders under the * following license. By obtaining, using and/or copying this software, * you agree that you have read, understood, and will comply with the * following terms and conditions: * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose and without fee or royalty is * hereby granted, provided that the full text of this NOTICE appears on * ALL copies of the software and documentation or portions thereof, * including modifications, that you make. * * THIS SOFTWARE IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, * BUT NOT LIMITATION, COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR * WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR * THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY * THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. COPYRIGHT * HOLDERS WILL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE OR * DOCUMENTATION. * * This software is provided AS IS, WITHOUT REPRESENTATION FROM THE * UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY PURPOSE, AND * WITHOUT WARRANTY BY THE UNIVERSITY OF MICHIGAN OF ANY KIND, EITHER * EXPRESSED OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE REGENTS * OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE FOR ANY DAMAGES, * INCLUDING SPECIAL , INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, * WITH RESPECT TO ANY CLAIM ARISING OUT OF OR IN CONNECTION WITH THE * USE OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN IF IT HAS * BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF SUCH DAMAGES * * The names and trademarks of copyright holders or authors may NOT be * used in advertising or publicity pertaining to the software without * specific, written prior permission. Title to copyright in this software * and any associated documentation will at all times remain with copyright * holders. */#include "disksim_global.h"#include "disksim_stat.h"#include "disksim_iosim.h"#include "disksim_iotrace.h"#include "disksim_iodriver.h"#include "disksim_logorg.h"#include "disksim_orgface.h"#include "disksim_ioqueue.h"#include "disksim_bus.h"#include "disksim_controller.h"#include "config.h"#include "modules/disksim_iodriver_param.h"/* read-only globals used during readparams phase */static char *statdesc_emptyqueue = "Empty queue delay";static char *statdesc_initiatenext = "Initiate next delay";struct iodriver *getiodriverbyname(char *name, int *num) { int c; if(!disksim->iodriver_info) return 0; for(c = 0; c < numiodrivers; c++) { if(iodrivers[c]) if(!strcmp(iodrivers[c]->name, name)) { if(num) *num = c; return iodrivers[c]; } } return 0;}static void iodriver_send_event_down_path (ioreq_event *curr){ intchar busno; intchar slotno; busno.value = curr->busno; slotno.value = curr->slotno; slotno.byte[0] = slotno.byte[0] & 0x0F;/*fprintf (outputfile, "iodriver_send_event_down_path: busno %d, slotno %d\n", busno.byte[0], slotno.byte[0]);*/ bus_deliver_event(busno.byte[0], slotno.byte[0], curr);}double iodriver_raise_priority (int iodriverno, int opid, int devno, int blkno, void *chan){ logorg_raise_priority(sysorgs, numsysorgs, opid, devno, blkno, chan); return(0.0);}static void schedule_disk_access (iodriver *curriodriver, ioreq_event *curr){ int queuectlr = curriodriver->devices[(curr->devno)].queuectlr; if (queuectlr != -1) { curriodriver->ctlrs[queuectlr].numoutstanding++; } curriodriver->devices[(curr->devno)].busy = TRUE;}static int check_send_out_request (iodriver *curriodriver, int devno){ int numout; if ((curriodriver->consttime == IODRIVER_TRACED_QUEUE_TIMES) || (curriodriver->consttime == IODRIVER_TRACED_BOTH_TIMES)) { return(FALSE); } numout = ioqueue_get_reqoutstanding(curriodriver->devices[devno].queue); if (curriodriver->usequeue == TRUE) { int queuectlr = curriodriver->devices[devno].queuectlr; if (queuectlr != -1) { numout = curriodriver->ctlrs[queuectlr].numoutstanding;/*fprintf (outputfile, "Check send_out_req: queuectlr %d, numout %d, maxout %d, send %d\n", queuectlr, numout, curriodriver->ctlrs[queuectlr].maxoutstanding, (numout < curriodriver->ctlrs[queuectlr].maxoutstanding));*/ return(numout < curriodriver->ctlrs[queuectlr].maxoutstanding); } else { return(numout < curriodriver->devices[devno].maxoutstanding); } } else { return(!numout); }}static ioreq_event * handle_new_request (iodriver *curriodriver, ioreq_event *curr){ struct ioq *queue = curriodriver->devices[(curr->devno)].queue; ioreq_event *ret = NULL; /* fprintf(outputfile, "\n*** handle_new_request:: time %f, devno %d, blkno %d, bcount %d\n\n", simtime, curr->devno, curr->blkno, curr->bcount); fprintf(outputfile, "handle_new_request:: calling ioqueue_add_new_request\n"); */ ioqueue_add_new_request(queue, curr); if (check_send_out_request(curriodriver, curr->devno)) { /* fprintf(outputfile, "handle_new_request:: calling ioqueue_get_next_request\n"); */ ret = ioqueue_get_next_request(queue); if (ret != NULL) { schedule_disk_access(curriodriver, ret); ret->time = IODRIVER_IMMEDSCHED_TIME * curriodriver->scale; } } return(ret);}void iodriver_schedule (int iodriverno, ioreq_event *curr){ ctlr *ctl;/*fprintf (outputfile, "Entered iodriver_schedule - devno %d, blkno %d, bcount %d, read %d\n", curr->devno, curr->blkno, curr->bcount, (curr->flags & READ));*/ ASSERT1(curr->type == IO_ACCESS_ARRIVE, "curr->type", curr->type); if ((iodrivers[iodriverno]->consttime != 0.0) && (iodrivers[iodriverno]->consttime != IODRIVER_TRACED_QUEUE_TIMES)) { curr->type = IO_INTERRUPT; if (iodrivers[iodriverno]->consttime > 0.0) { curr->time = iodrivers[iodriverno]->consttime; } else { curr->time = ((double) curr->tempint2 / (double) 1000); } curr->cause = COMPLETION; intr_request((event *) curr); return; } ctl = iodrivers[iodriverno]->devices[(curr->devno)].ctl; if ((ctl) && (ctl->flags & DRIVER_C700)) { if ((ctl->pendio) && ((curr->devno != ctl->pendio->next->devno) || (curr->opid != ctl->pendio->next->opid) || (curr->blkno != ctl->pendio->next->blkno))) { curr->next = ctl->pendio->next; ctl->pendio->next = curr; ctl->pendio = curr; return; } else if (ctl->pendio == NULL) { ctl->pendio = ioreq_copy(curr); ctl->pendio->next = ctl->pendio; } if (ctl->flags & DRIVER_CTLR_BUSY) { addtoextraq((event *) curr); return; } } curr->busno = iodrivers[iodriverno]->devices[(curr->devno)].buspath.value; curr->slotno = iodrivers[iodriverno]->devices[(curr->devno)].slotpath.value; if (iodrivers[iodriverno]->devices[(curr->devno)].queuectlr != -1) { int ctlrno = iodrivers[iodriverno]->devices[(curr->devno)].queuectlr; ctl = &iodrivers[iodriverno]->ctlrs[ctlrno]; if ((ctl->maxreqsize) && (curr->bcount > ctl->maxreqsize)) { ioreq_event *totalreq = ioreq_copy(curr);/*fprintf (outputfile, "%f, oversized request: opid %d, blkno %d, bcount %d, maxreqsize %d\n", simtime, curr->opid, curr->blkno, curr->bcount, ctl->maxreqsize);*/ curr->bcount = ctl->maxreqsize; if (ctl->oversized) { totalreq->next = ctl->oversized->next; ctl->oversized->next = totalreq; } else { totalreq->next = totalreq; ctl->oversized = totalreq; } } } iodriver_send_event_down_path(curr);/*fprintf (outputfile, "Leaving iodriver_schedule\n");*/}static void update_iodriver_statistics(){}static void iodriver_check_c700_based_status (iodriver *curriodriver, int devno, int cause, int type, int blkno){ ctlr *ctl; ioreq_event *tmp; ctl = curriodriver->devices[devno].ctl; if ((ctl == NULL) || (!(ctl->flags & DRIVER_C700))) { return; } if (type == IO_INTERRUPT_ARRIVE) { if (ctl->pendio != NULL) { tmp = ctl->pendio->next; if ((tmp->devno == devno) && (tmp->blkno == blkno)) { if (ctl->pendio == tmp) { ctl->pendio = NULL; } else { ctl->pendio->next = tmp->next; } addtoextraq((event *) tmp); } } switch (cause) { case COMPLETION: case DISCONNECT: case RECONNECT: case READY_TO_TRANSFER: ctl->flags |= DRIVER_CTLR_BUSY; break; default: fprintf(stderr, "Unknown interrupt cause at iodriver_check_c700_based_status - cause %d\n", cause); exit(1); } } else { switch (cause) { case COMPLETION: case DISCONNECT: ctl->flags &= ~DRIVER_CTLR_BUSY; if (ctl->pendio != NULL) { tmp = ioreq_copy(ctl->pendio->next); tmp->time = simtime; addtointq((event *) tmp); } break; case RECONNECT: case READY_TO_TRANSFER: ctl->flags |= DRIVER_CTLR_BUSY; break; default: fprintf(stderr, "Unknown interrupt cause at iodriver_check_c700_based_status - cause %d\n", cause); exit(1); } }}/* Should only be called for completion interrupts!!!!! */static void iodriver_add_to_intrp_eventlist (intr_event *intrp, event *curr, double scale){ if (curr) { event *tmp = intrp->eventlist; int lasttype = curr->type; intrp->eventlist = curr; if (curr->type == IO_ACCESS_ARRIVE) { curr->time = IODRIVER_COMPLETION_RESPTOSCHED_TIME; } else if (curr->type == IO_REQUEST_ARRIVE) { curr->time = IODRIVER_COMPLETION_RESPTOREQ_TIME; } else { /* Assume wakeup */ curr->time = IODRIVER_COMPLETION_RESPTOWAKEUP_TIME; } curr->time *= scale; while (curr->next) { curr = curr->next; curr->time = 0.0; } curr->next = tmp; if (lasttype != IO_REQUEST_ARRIVE) { while (tmp) { if (tmp->type == INTEND_EVENT) { ASSERT(tmp->next == NULL); tmp->time = (lasttype == IO_ACCESS_ARRIVE) ? IODRIVER_COMPLETION_SCHEDTOEND_TIME : IODRIVER_COMPLETION_WAKEUPTOEND_TIME; tmp->time *= scale; } else if (tmp->type != IO_REQUEST_ARRIVE) { /* assume wakeup */ tmp->time = (lasttype == IO_ACCESS_ARRIVE) ? IODRIVER_COMPLETION_SCHEDTOWAKEUP_TIME : 0.0; lasttype = tmp->type; tmp->time *= scale; } tmp = tmp->next; } } }}void iodriver_access_complete (int iodriverno, intr_event *intrp){ int i; int numreqs; ioreq_event *tmp; ioreq_event *del; ioreq_event *req; int devno; int skip = 0; ctlr *ctl = NULL; if (iodrivers[iodriverno]->type == STANDALONE) { req = ioreq_copy((ioreq_event *) intrp->infoptr); } else { req = (ioreq_event *) intrp->infoptr; }/* fprintf (outputfile, "\n*** Request completing - time %f, devno %d, blkno %d\n\n", simtime, req->devno, req->blkno);*/ // fprintf (stdout, "Request completing - time %f, devno %d, blkno %d\n", simtime, req->devno, req->blkno);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -