Esempio n. 1
0
VM::VM(ModelPtr model, const char *name, xbt_dict_t props,
		        RoutingEdgePtr netElm, CpuPtr cpu)
: Host(model, name, props, NULL, netElm, cpu)
{
  VMModel::ws_vms.push_back(*this);
  surf_callback_emit(VMCreatedCallbacks, this);
}
Esempio n. 2
0
Cpu::Cpu(Model *model, const char *name, xbt_dict_t props,
		 lmm_constraint_t constraint, int core, double powerPeak, double powerScale)
 : Resource(model, name, props, constraint)
 , m_core(core)
 , m_powerPeak(powerPeak)
 , m_powerScale(powerScale)
{
  surf_callback_emit(cpuCreatedCallbacks, this);
  /* At now, we assume that a VM does not have a multicore CPU. */
  if (core > 1)
    xbt_assert(model == surf_cpu_model_pm);

  p_constraintCore = NULL;
  p_constraintCoreId = NULL;
  if (model->getUpdateMechanism() != UM_UNDEFINED) {
	p_constraintCore = xbt_new(lmm_constraint_t, core);
	p_constraintCoreId = xbt_new(void*, core);

    int i;
    for (i = 0; i < core; i++) {
      /* just for a unique id, never used as a string. */
      p_constraintCoreId[i] = bprintf("%s:%i", name, i);
      p_constraintCore[i] = lmm_constraint_new(model->getMaxminSystem(), p_constraintCoreId[i], m_powerScale * m_powerPeak);
    }
  }
Esempio n. 3
0
Storage::~Storage(){
  surf_callback_emit(storageDestructedCallbacks, this);
  xbt_dict_free(&p_content);
  xbt_dynar_free(&p_writeActions);
  free(p_typeId);
  free(p_contentType);
  free(p_attach);
}
Esempio n. 4
0
Cpu::Cpu(Model *model, const char *name, xbt_dict_t props,
		 int core, double powerPeak, double powerScale)
 : Resource(model, name, props)
 , m_core(core)
 , m_powerPeak(powerPeak)
 , m_powerScale(powerScale)
 , p_constraintCore(NULL)
 , p_constraintCoreId(NULL)
{
  surf_callback_emit(cpuCreatedCallbacks, this);
}
Esempio n. 5
0
Storage::Storage(Model *model, const char *name, xbt_dict_t props,
                 const char* type_id, char *content_name, char *content_type,
                 sg_size_t size)
 : Resource(model, name, props)
 , p_contentType(content_type)
 , m_size(size), m_usedSize(0)
 , p_typeId(xbt_strdup(type_id))
 , p_writeActions(xbt_dynar_new(sizeof(Action*),NULL))
{
  surf_callback_emit(storageCreatedCallbacks, this);
  p_content = parseContent(content_name);
  setState(SURF_RESOURCE_ON);
}
Esempio n. 6
0
ActionPtr NetworkConstantModel::communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
		                         double size, double rate)
{
  char *src_name = src->getName();
  char *dst_name = dst->getName();

  XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
  NetworkConstantActionPtr action = new NetworkConstantAction(this, size, sg_latency_factor);
  XBT_OUT();

  surf_callback_emit(networkCommunicateCallbacks, action, src, dst, size, rate);
  return action;
}
Esempio n. 7
0
Storage::Storage(Model *model, const char *name, xbt_dict_t props,
                 lmm_system_t maxminSystem, double bread, double bwrite,
                 double bconnection, const char* type_id, char *content_name,
                 char *content_type, sg_size_t size, char *attach)
 :  Resource(model, name, props, lmm_constraint_new(maxminSystem, this, bconnection))
 , p_contentType(content_type)
 , m_size(size), m_usedSize(0)
 , p_typeId(xbt_strdup(type_id))
 , p_writeActions(xbt_dynar_new(sizeof(Action*),NULL)) {
  surf_callback_emit(storageCreatedCallbacks, this);
  p_content = parseContent(content_name);
  p_attach = xbt_strdup(attach);
  setState(SURF_RESOURCE_ON);
  XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
  p_constraintRead  = lmm_constraint_new(maxminSystem, this, bread);
  p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);
}
Esempio n. 8
0
Cpu::Cpu(){
  surf_callback_emit(cpuCreatedCallbacks, this);
}
Esempio n. 9
0
void VM::setState(e_surf_resource_state_t state){
  Resource::setState(state);
  surf_callback_emit(VMStateChangedCallbacks, this);
}
Esempio n. 10
0
/*
 * A physical host does not disapper in the current SimGrid code, but a VM may
 * disapper during a simulation.
 */
VM::~VM()
{
  surf_callback_emit(VMDestructedCallbacks, this);
  VMModel::ws_vms.erase(VMModel::
                                   vm_list_t::s_iterator_to(*this));
}
Esempio n. 11
0
void Storage::setState(e_surf_resource_state_t state)
{
  e_surf_resource_state_t old = Resource::getState();
  Resource::setState(state);
  surf_callback_emit(storageStateChangedCallbacks, this, old, state);
}