예제 #1
0
bool DynamicOutputManager::checkDynamicCancel(const Event* event) {
    //This method will just perform the LazyOutputManager::checkLazyCancelEvent.
    //Based on the bool result, a hit or miss will be recorded.
    //Messages are only suppressed when the current mode is Lazy and there is a hit.
    //The curMeasured will be kept track of using the filterdepth.
    //The event will not be inserted and events will not be cancelled.

    bool suppressMessage = false;
    bool lazyCancelHit = false;
    int numCancelledEvents = 0;
    SimulationObject* sender = getSimulationManager()->getObjectHandle(event->getSender());
    int objID = sender->getObjectID()->getSimulationObjectID();

    // Only do the check if there are any events to check.
    if ((lazyQueues[objID])->size() > 0) {
        if (!permanentlyAggressive[objID]) {
            setCompareMode(sender, curCancelMode[objID] == LAZY);
            lazyCancelHit = LazyOutputManager::checkLazyCancelEvent(event);
            numCancelledEvents = (eventsToCancel[objID])->size();

            if (curCancelMode[objID] == LAZY) {
                suppressMessage = lazyCancelHit;
                if (lazyCancelHit && getCompareMode(sender)) {
                    //Inserting the original event, reclaim this one.
                    sender->reclaimEvent(event);
                } else {
                    OutputManagerImplementationBase::insert(event);
                }
                LazyOutputManager::handleCancelEvents(sender);
            } else {
                eventsToCancel[objID]->clear();
                OutputManagerImplementationBase::insert(event);
            }

            // Record a lazy hit.
            if (lazyCancelHit) {
                (*(comparisonResults[objID]))[curMeasured[objID] % filterDepth] = 1;
                curMeasured[objID] = curMeasured[objID] + 1;
            }

            // Record a lazy miss.
            // Misses may have to be recorded as the size of the cancellation queue eventsToCancel.
            for (int i = 0; i < numCancelledEvents ; i++) {
                (*(comparisonResults[objID]))[curMeasured[objID] % filterDepth] = 0;
                curMeasured[objID] = curMeasured[objID] + 1;;
            }

            if (curMeasured[objID] >= filterDepth) {
                determineCancellationMode(objID);
                curMeasured[objID] = 0;
            }
        } else {
            OutputManagerImplementationBase::insert(event);
        }
    } else {
        OutputManagerImplementationBase::insert(event);
    }

    return suppressMessage;
}
예제 #2
0
bool
DefaultTimeWarpEventSet::insert( const Event *event ){
  bool retval = false;
  ASSERT( event != 0 );
  SimulationObject *object = mySimulationManager->getObjectHandle( event->getReceiver() );
  ASSERT( object != 0 );
  if( event->getReceiveTime() < object->getSimulationTime() ){
    retval = true;
  }
  getEventContainer( object->getObjectID() ).insert( event );
  return retval;
}
예제 #3
0
void RAIDDisk::executeProcess() {
	RAIDRequest *recvEvent;
	RAIDDiskState *myState;
	RAIDRequest *newEvent;
	RAIDRequest *tmpEvent;
	IntVTime recvTime(0);
	int seekDist;
	double seekTime, a, b, c;
	int nextCylinder;
	int timeDelay = 1;
    int objectId;

	IntVTime sendTime = dynamic_cast<const IntVTime&> (getSimulationTime());

	myState = (RAIDDiskState *) getState();

	while (true == haveMoreEvents()) {
		recvEvent = (RAIDRequest*) getEvent();

		if (recvEvent != NULL) {
			SimulationObject *recvr = getObjectHandle(
					recvEvent->getSourceObject());
            string receiverName = recvr->getName();
            objectId=recvr->getObjectID()->getSimulationObjectID();
            tmpEvent = new RAIDRequest(sendTime, sendTime + 1, this, recvr);
            *tmpEvent = *recvEvent;

			nextCylinder = (tmpEvent->getStartStripe() / (sectorsPerTrack
					* tracksPerCyl)) % numCylinders;
			tmpEvent->setStartCylinder(nextCylinder);
			tmpEvent->setStartSector(
					tmpEvent->getStartStripe() % sectorsPerTrack);

			seekDist = nextCylinder - myState->getCurrentCylinder();

			myState = (RAIDDiskState*) getState();

			if (seekDist < 0) {
				seekDist = abs(seekDist);
			}
			if (seekDist != 0) {
				a = (-10 * minSeekTime + 15 * avgSeekTime - 5 * maxSeekTime)
						/ (3 * sqrt(numCylinders));
				b = (7 * minSeekTime - 15 * avgSeekTime + 8 * maxSeekTime) / (3
						* numCylinders);
				c = minSeekTime;
				if (a > 0 && b > 0) {
					seekTime = a * sqrt(seekDist - 1) + b * (seekDist - 1) + c;
				} else {
					cerr << "Disk Model parameters are not correct for model"
							<< endl;
					seekTime = 0;
				}
			} else {
				seekTime = 0;
			}

			recvTime = max(sendTime.getApproximateIntTime(), lastEventTime[receiverName])
					+ int(seekTime + 0.5 * revolutionTime);
           // recvTime = lastEventTime + int(seekTime + 0.5 * revolutionTime);

			newEvent = new RAIDRequest(sendTime, recvTime, this, recvr);
			//delete lastEventTime;
			lastEventTime[receiverName] = recvTime.getApproximateIntTime();
			//cout << "LastEvent Time for the Disk = " << lastEventTime << endl;
#if 0
			recvTime = VTime(getSimulationTime() +
					int(seekTime + 0.5*revolutionTime) + timeDelay++);
			newEvent = new RAIDRequest(sendTime, recvTime, this, recvr);
#endif
			*newEvent = *tmpEvent;

			delete tmpEvent;

			myState->setCurrentCylinder(nextCylinder);

			// Send event back to source.
			recvr->receiveEvent(newEvent);
		} // End of if (event != null)
	} // End of while "have more events" loop
}