float avgCriterion(List* alreadyJobs) { Node* iterator; unsigned int jobQuantum = 0; unsigned int remainingTime = 0; float avg = 0; Job* job; if(alreadyJobs->size == 0) return 0; iteratorStart(alreadyJobs); while ((iterator = iteratorNext(alreadyJobs)) != NULL) { job = (Job*) iterator->value; remainingTime = job->service_time - job->currentStep; jobQuantum = CURRENT_QUANTUM(job->currentStep); avg += SHEDULER_CRITERION(job->priority, remainingTime, jobQuantum); } avg /= alreadyJobs->size; return avg; }
void ByteSection::outTab(ofstream *output) { ofstream &out = *output; // dopunjavanje do 4 bajta /*for (int i = cnt; i < 4; i++) { dw[i] = 0; } endInsert(dw); cnt = 0;*/ out << "#" << this->getName() << endl; dword *tek; int i=0; for (resetIterator(); getBoolIt(); iteratorNext()) { tek = getItEntPointer(); tek->outDword(output); out << " "; if ((i % 4) == 3) out << endl; i++; } if(i == 0) out << "(empty)"; out << endl; }
Job* getGreatestCriterionJob(List* alreadyQueue) { Job* job; Job* theJob = NULL; /*the greatest*/ Node* iterator; float maxCriterion = 0; float criterion = 0; unsigned int jobQuantum; unsigned int remainingTime; iteratorStart(alreadyQueue); while((iterator = iteratorNext(alreadyQueue)) != NULL) { job = (Job*) iterator->value; remainingTime = job->service_time - job->currentStep; jobQuantum = CURRENT_QUANTUM(job->currentStep); if((criterion = SHEDULER_CRITERION(job->priority, remainingTime, jobQuantum)) >= maxCriterion) { maxCriterion = criterion; theJob = job; } } /*remove da lista de prontos o job selecionado*/ if(theJob != NULL) removeByValue(alreadyQueue, theJob); return theJob; }
void* scheduling(List* cores, List* alreadyQueue, List* waitingQueue, List* finishedQueue, int policy) { Core* core; Node* iterator; float avg; float criterion = 0; int remainingTime = 0; int jobQuantum = 0; avg = avgCriterion(alreadyQueue); iteratorStart(cores); while((iterator = iteratorNext(cores)) != NULL) { core = (Core*) iterator->value; if(alreadyQueue->size > 0) { if(core->currentJob == NULL) makeBasicScheduling(core, alreadyQueue, policy); else if((core->currentJob->status == WAITING) || (core->currentJob->status == FINISHED)) makeSchedulingDueStatusJob(core, alreadyQueue, waitingQueue, finishedQueue, policy); else if((core->currentJob->currentStep > 0) && (CURRENT_QUANTUM(core->currentJob->currentStep) == 0)) makeSchedulingGap(core, alreadyQueue, policy); else if(policy == MY_POLICY) { remainingTime = core->currentJob->service_time - core->currentJob->currentStep; jobQuantum = CURRENT_QUANTUM(core->currentJob->currentStep); criterion = SHEDULER_CRITERION(core->currentJob->priority, remainingTime, jobQuantum); printf("\nP: %d - WP: %d\tSRT: %d - WSRT: %d\tQ: %d - WQ: %d", core->currentJob->priority, WP, remainingTime, WSRT, jobQuantum, WQ); printf("\tcriterion: %.2f \tavg: %.2f", criterion, avg); if((SHEDULER_DECISION(criterion, avg)) == 0) makeSchedulingGap(core, alreadyQueue, policy); } } else if((core->currentJob != NULL) && ((core->currentJob->status == WAITING) || (core->currentJob->status == FINISHED))) { if(core->currentJob->status == WAITING) add(waitingQueue, core->currentJob); else if(core->currentJob->status == FINISHED) add(finishedQueue, core->currentJob); core->currentJob = NULL; } } return 0; }
JSValue iteratorStep(ExecState* exec, JSValue iterator) { JSValue result = iteratorNext(exec, iterator); if (exec->hadException()) return jsUndefined(); bool done = iteratorComplete(exec, result); if (exec->hadException()) return jsUndefined(); if (done) return jsBoolean(false); return result; }
void ByteSection::replace(dword dw, int offset) { dword *tek; resetIterator(); for (int i = 0; i < offset / INS_SIZE; i++) iteratorNext(); tek = getItEntPointer(); tek->sumOr(dw); }
JSValue iteratorStep(ExecState* exec, IterationRecord iterationRecord) { VM& vm = exec->vm(); auto scope = DECLARE_THROW_SCOPE(vm); JSValue result = iteratorNext(exec, iterationRecord); RETURN_IF_EXCEPTION(scope, JSValue()); bool done = iteratorComplete(exec, result); RETURN_IF_EXCEPTION(scope, JSValue()); if (done) return jsBoolean(false); return result; }
void RelTab::outTab(ofstream *output) { ofstream &out = *output; string name = bTab->getName(); name = name.substr(0, 4); if (name.compare(".bss") == 0) return; out << "#.rel" << bTab->getName() << endl; out << "offset\t\tType\t\t\Val[" << bTab->getName() << "]:" << endl; Elf_Rel *tek; for (resetIterator(); getBoolIt(); iteratorNext()) { tek = getItEntPointer(); tek->outRel(output); } }
JSValue iteratorNext(ExecState* exec, JSValue iterator) { return iteratorNext(exec, iterator, JSValue()); }
void TMsmmNodeBase::DestroyNode() { OstTraceFunctionEntry0( TMSMMNODEBASE_DESTROYNODE_ENTRY ); TMsmmNodeBase* parentNode = iParent; TMsmmNodeBase* iterator(this); TMsmmNodeBase* iteratorPrev(NULL); TMsmmNodeBase* iteratorNext(NULL); if (parentNode) { // A parent node exists iterator = parentNode->iFirstChild; if (iterator) { // iteratorPrev equal NULL at beginning; iteratorNext= iterator->iNextPeer; } // Go through each child node to find the node to be destroyed while (iterator && (iterator != this)) { iteratorPrev = iterator; iterator = iteratorNext; if(iteratorNext) { iteratorNext = iteratorNext->iNextPeer; } } if (iterator) { // Matched node found if (parentNode->iLastChild == iterator) { parentNode->iLastChild = iteratorPrev; } if (iteratorPrev) { iteratorPrev->iNextPeer = iteratorNext; } else { parentNode->iFirstChild = iteratorNext; } } else { // No matched node OstTraceFunctionExit0( TMSMMNODEBASE_DESTROYNODE_EXIT ); return; } } // Remove all children node if (iFirstChild) { // Current node isn't a leaf node iterator = iFirstChild; iteratorNext= iterator->iNextPeer; while (iterator) { delete iterator; iterator = iteratorNext; if (iteratorNext) { iteratorNext = iterator->iNextPeer; } } } OstTraceFunctionExit0( TMSMMNODEBASE_DESTROYNODE_EXIT_DUP1 ); }