static void ssd_media_access_request_element (ioreq_event *curr) { ssd_t *currdisk = getssd(curr->devno); int blkno = curr->blkno; int count = curr->bcount; /* **** CAREFUL ... HIJACKING tempint2 and tempptr2 fields here **** */ curr->tempint2 = count; while (count != 0) { // find the element (package) to direct the request int elem_num = currdisk->timing_t->choose_element(currdisk->timing_t, blkno); ssd_element *elem = &currdisk->elements[elem_num]; // create a new sub-request for the element ioreq_event *tmp = (ioreq_event *)getfromextraq(); tmp->devno = curr->devno; tmp->busno = curr->busno; tmp->flags = curr->flags; tmp->blkno = blkno; tmp->bcount = ssd_choose_aligned_count(currdisk->params.page_size, blkno, count); ASSERT(tmp->bcount == currdisk->params.page_size); tmp->tempptr2 = curr; blkno += tmp->bcount; count -= tmp->bcount; elem->metadata.reqs_waiting ++; // add the request to the corresponding element's queue ioqueue_add_new_request(elem->queue, (ioreq_event *)tmp); ssd_activate_elem(currdisk, elem_num); } }
static void ssd_media_access_request_element (ioreq_event *curr) { ssd_t *currdisk = getssd(curr->devno); int blkno = curr->blkno; int count = curr->bcount; //added by tiel int i = 0; double max_threshold = currdisk->params.nelements * currdisk->params.page_size; /* **** CAREFUL ... HIJACKING tempint2 and tempptr2 fields here **** */ curr->tempint2 = count; //while (count != 0) { while (count > 0) { // find the element (package) to direct the request int elem_num = ssd_choose_element(currdisk->user_params, blkno); ssd_element *elem = &currdisk->elements[elem_num]; // create a new sub-request for the element ioreq_event *tmp = (ioreq_event *)getfromextraq(); tmp->devno = curr->devno; tmp->busno = curr->busno; tmp->flags = curr->flags; tmp->blkno = blkno; tmp->bcount = ssd_choose_aligned_count(currdisk->params.page_size, blkno, count); /*if(curr->bcount > max_threshold) tmp->tempint1 = 1;*/ //ASSERT(tmp->bcount == currdisk->params.page_size); tmp->tempptr2 = curr; blkno += tmp->bcount; count -= tmp->bcount; elem->metadata.reqs_waiting ++; // add the request to the corresponding element's queue ioqueue_add_new_request(elem->queue, (ioreq_event *)tmp); // added by tiel // activate request create simtime, type, elem_num { int ch_num; double wtime, ctime; ioreq_event *temp = (ioreq_event *)getfromextraq(); temp->type = SSD_ACTIVATE_ELEM; //Insert Channel/Way delay //Channel Number = Chip number % Number of Channel ch_num = elem_num % currdisk->params.nchannel; wtime = currdisk->CH[ch_num].arrival_time + ssd_data_transfer_cost(currdisk,currdisk->params.page_size); ctime = simtime + (i * currdisk->params.channel_switch_delay); if(currdisk->params.nchannel == currdisk->params.nelements){ temp->time = ctime; currdisk->CH[ch_num].ccount++; }else if(simtime > wtime || currdisk->CH[ch_num].flag == -1){ //channel data setting currdisk->CH[ch_num].arrival_time = ctime; currdisk->CH[ch_num].flag = curr->flags; temp->time = ctime; currdisk->CH[ch_num].ccount++; }else if(currdisk->CH[ch_num].flag ==READ){ if(wtime > ctime){ if(curr->flags == READ){ temp->time = wtime; }else{ temp->time = wtime + currdisk->params.page_read_latency; } currdisk->CH[ch_num].wcount++; }else{ temp->time = ctime; currdisk->CH[ch_num].ccount++; } currdisk->CH[ch_num].arrival_time = temp->time; currdisk->CH[ch_num].flag = curr->flags; }else if(currdisk->CH[ch_num].flag == WRITE){ if(wtime > ctime){ temp->time = wtime; currdisk->CH[ch_num].wcount++; }else{ temp->time = ctime; currdisk->CH[ch_num].ccount++; } currdisk->CH[ch_num].arrival_time = temp->time; currdisk->CH[ch_num].flag = curr->flags; } temp->ssd_elem_num = elem_num; addtointq ((event *)temp); i ++; } } }