GreenCloud Simulator
Public Member Functions | Public Attributes | Private Attributes | List of all members
TaskAlloc Class Reference

#include <taskalloc.h>

Collaboration diagram for TaskAlloc:
Collaboration graph
[legend]

Public Member Functions

 TaskAlloc (CloudTask *ct, int rd, int cap)
 
virtual ~TaskAlloc ()
 
double getMIPS ()
 
double getDeadline ()
 
void setExecTime (double execTime)
 
void setCoreScheduler (CoreScheduler *cs)
 
CoreSchedulergetCoreScheduler ()
 
bool operator== (const TaskAlloc &other) const
 
void setComputingRate (double rate)
 
double execTime ()
 
void updateMIPS ()
 
void removeAfterFailure ()
 
void print ()
 

Public Attributes

CloudTaskcloudTask
 
CoreSchedulercore
 
double executedSince_
 

Private Attributes

int rd
 
int cap
 

Detailed Description

Definition at line 14 of file taskalloc.h.

Constructor & Destructor Documentation

TaskAlloc::TaskAlloc ( CloudTask ct,
int  rd,
int  cap 
)

Definition at line 16 of file taskalloc.cc.

16  : core(NULL),executedSince_(0.0){
17  this->cloudTask = ct;
18  this->rd = rd;
19  this->cap = cap;
20 }
CoreScheduler * core
Definition: taskalloc.h:19
int rd
Definition: taskalloc.h:39
int cap
Definition: taskalloc.h:40
double executedSince_
Definition: taskalloc.h:20
CloudTask * cloudTask
Definition: taskalloc.h:17
TaskAlloc::~TaskAlloc ( )
virtual

Definition at line 12 of file taskalloc.cc.

12  {
13 
14 }

Member Function Documentation

double TaskAlloc::execTime ( )

Definition at line 73 of file taskalloc.cc.

74 {
75  if (cloudTask->res_demands.at(rd)->current_performance.at(cap)){
76  return ((double)(cloudTask->res_demands.at(rd)->capacity.at(cap))/cloudTask->res_demands.at(rd)->current_performance.at(cap));
77  }
78  else{
79  return DBL_MAX;
80  }
81 }
int rd
Definition: taskalloc.h:39
int cap
Definition: taskalloc.h:40
std::vector< ResDemand * > res_demands
CloudTask * cloudTask
Definition: taskalloc.h:17
CoreScheduler * TaskAlloc::getCoreScheduler ( )

Definition at line 31 of file taskalloc.cc.

31  {
32  return this->core;
33 }
CoreScheduler * core
Definition: taskalloc.h:19
double TaskAlloc::getDeadline ( )

Definition at line 24 of file taskalloc.cc.

24  {
25  return cloudTask->getDeadline();
26 }
double getDeadline()
Definition: cloudtask.h:23
CloudTask * cloudTask
Definition: taskalloc.h:17
double TaskAlloc::getMIPS ( )

Definition at line 21 of file taskalloc.cc.

21  {
22  return cloudTask->getMIPS(rd,cap);
23 }
double getMIPS(int rd, int cap)
Definition: cloudtask.cc:52
int rd
Definition: taskalloc.h:39
int cap
Definition: taskalloc.h:40
CloudTask * cloudTask
Definition: taskalloc.h:17
bool TaskAlloc::operator== ( const TaskAlloc other) const

Definition at line 35 of file taskalloc.cc.

35  {
36  if(cloudTask==other.cloudTask && rd == other.rd && cap == other.cap){
37  return true;
38  } else {
39  return false;
40  }
41 }
int rd
Definition: taskalloc.h:39
int cap
Definition: taskalloc.h:40
CloudTask * cloudTask
Definition: taskalloc.h:17
void TaskAlloc::print ( )

Definition at line 50 of file taskalloc.cc.

50  {
51  std::cerr << "id "<< cloudTask->id_ << " "<< rd << " ,c: " << cap << " mips left: " << getMIPS() << "\texec since: " << executedSince_;
52 }
int rd
Definition: taskalloc.h:39
int cap
Definition: taskalloc.h:40
double getMIPS()
Definition: taskalloc.cc:21
int id_
Definition: cloudtask.h:51
double executedSince_
Definition: taskalloc.h:20
CloudTask * cloudTask
Definition: taskalloc.h:17
void TaskAlloc::removeAfterFailure ( )
void TaskAlloc::setComputingRate ( double  rate)

Definition at line 43 of file taskalloc.cc.

44 {
45  /* update what has already been computed */
46  updateMIPS();
47  cloudTask->res_demands.at(rd)->current_performance.at(cap)= rate;
48 }
int rd
Definition: taskalloc.h:39
int cap
Definition: taskalloc.h:40
std::vector< ResDemand * > res_demands
void updateMIPS()
Definition: taskalloc.cc:54
CloudTask * cloudTask
Definition: taskalloc.h:17
void TaskAlloc::setCoreScheduler ( CoreScheduler cs)

Definition at line 28 of file taskalloc.cc.

28  {
29  this->core=cs;
30 }
CoreScheduler * core
Definition: taskalloc.h:19
void TaskAlloc::setExecTime ( double  execTime)
inline

Definition at line 28 of file taskalloc.h.

double executedSince_
Definition: taskalloc.h:20
double execTime()
Definition: taskalloc.cc:73
void TaskAlloc::updateMIPS ( )

Definition at line 54 of file taskalloc.cc.

55 {
56  ResDemand* res_dem = cloudTask->res_demands.at(rd);
57 
58  double operationsComputed = (res_dem)->current_performance.at(cap)*(Scheduler::instance().clock() - executedSince_);
59 
60  if((res_dem)->capacity.at(cap) > operationsComputed){
61  (res_dem)->capacity.at(cap) -= operationsComputed;
62  } else {
63  (res_dem)->capacity.at(cap) = 0;
64  }
65 // std::cout << "--\t Task: " << this->cloudTask->id_ << " MIPS: " << getMIPS() << "\n";
66 
67 
68  executedSince_ = Scheduler::instance().clock();
69 }
int rd
Definition: taskalloc.h:39
int cap
Definition: taskalloc.h:40
std::vector< ResDemand * > res_demands
double executedSince_
Definition: taskalloc.h:20
CloudTask * cloudTask
Definition: taskalloc.h:17

Member Data Documentation

int TaskAlloc::cap
private

capacity

Definition at line 40 of file taskalloc.h.

CloudTask* TaskAlloc::cloudTask

Definition at line 17 of file taskalloc.h.

CoreScheduler* TaskAlloc::core

Definition at line 19 of file taskalloc.h.

double TaskAlloc::executedSince_

last time instance of task execution

Definition at line 20 of file taskalloc.h.

int TaskAlloc::rd
private

resource demand

Definition at line 39 of file taskalloc.h.


The documentation for this class was generated from the following files: