Skip to content

Commit

Permalink
fix cpuSpeed conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
linofex committed Jul 14, 2023
1 parent bde2824 commit b4e2b2f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void VirtualisationInfrastructureManager::initialize(int stage)

maxRam = mecHost->par("maxRam").doubleValue();
maxDisk = mecHost->par("maxDisk").doubleValue();
maxCPU = mecHost->par("maxCpuSpeed").doubleValue()*pow(10,6);
maxCPU = mecHost->par("maxCpuSpeed").doubleValue();

allocatedRam = 0.0;
allocatedDisk = 0.0;
Expand Down Expand Up @@ -498,7 +498,7 @@ bool VirtualisationInfrastructureManager::registerMecApp(int ueAppID, int reqRam
appEntry.ueAppID = ueAppID;
appEntry.resources.ram = reqRam;
appEntry.resources.disk = reqDisk;
double cpu = (double)reqCpu * pow(10,6);
double cpu = (double)reqCpu ;
appEntry.resources.cpu = cpu;
mecAppMap.insert({ueAppID, appEntry});

Expand Down Expand Up @@ -539,17 +539,20 @@ double VirtualisationInfrastructureManager::calculateProcessingTime(int ueAppID,
if(ueApp != mecAppMap.end())
{
double time;
double currentSpeed;
if(scheduling == FAIR_SHARING)
{
double currentSpeed = ueApp->second.resources.cpu *(maxCPU/allocatedCPU);
time = numOfInstructions/currentSpeed;
currentSpeed = ueApp->second.resources.cpu *(maxCPU/allocatedCPU);
time = numOfInstructions/(pow(10,6)*currentSpeed);
}
else
{
double currentSpeed = ueApp->second.resources.cpu;
time = numOfInstructions/currentSpeed;
currentSpeed = ueApp->second.resources.cpu;
time = numOfInstructions/(pow(10,6)*currentSpeed);
}
EV << "VirtualisationInfrastructureManager::calculateProcessingTime - calculated time: " << time << endl;
EV << "VirtualisationInfrastructureManager::calculateProcessingTime - number of instructions: " << numOfInstructions << endl;
EV << "VirtualisationInfrastructureManager::calculateProcessingTime - currentSpeed (MIPS): " << currentSpeed << endl;
EV << "VirtualisationInfrastructureManager::calculateProcessingTime - calculated time: " << time << "s"<< endl;

return time;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ class VirtualisationInfrastructureManager : public cSimpleModule
* utility
*/
void printResources(){
EV << "VirtualisationInfrastructureManager::printResources - allocated Ram: " << allocatedRam << " / " << maxRam << endl;
EV << "VirtualisationInfrastructureManager::printResources - allocated Disk: " << allocatedDisk << " / " << maxDisk << endl;
EV << "VirtualisationInfrastructureManager::printResources - allocated CPU: " << allocatedCPU << " / " << maxCPU << endl;
EV << "VirtualisationInfrastructureManager::printResources - allocated Ram (B): " << allocatedRam << " / " << maxRam << endl;
EV << "VirtualisationInfrastructureManager::printResources - allocated Disk (B): " << allocatedDisk << " / " << maxDisk << endl;
EV << "VirtualisationInfrastructureManager::printResources - allocated CPU (MIPS): " << allocatedCPU << " / " << maxCPU << endl;
}

protected:
Expand Down

0 comments on commit b4e2b2f

Please sign in to comment.