-/* Copyright (c) 2013-2014. The SimGrid Team.
+/* Copyright (c) 2013-2015. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include "host_interface.hpp"
-#include "simix/smx_private.h"
+#include "src/simix/smx_private.h"
#include "cpu_cas01.hpp"
#include "simgrid/sg_config.h"
#include "network_interface.hpp"
-#include "vm_interface.hpp"
+#include "virtual_machine.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_host, surf,
"Logging specific to the SURF host module");
-HostModelPtr surf_host_model = NULL;
+HostModel *surf_host_model = NULL;
/*************
* Callbacks *
*************/
-surf_callback(void, HostPtr) hostCreatedCallbacks;
-surf_callback(void, HostPtr) hostDestructedCallbacks;
-surf_callback(void, HostPtr, e_surf_resource_state_t, e_surf_resource_state_t) hostStateChangedCallbacks;
-surf_callback(void, HostActionPtr, e_surf_action_state_t, e_surf_action_state_t) hostActionStateChangedCallbacks;
+surf_callback(void, Host*) hostCreatedCallbacks;
+surf_callback(void, Host*) hostDestructedCallbacks;
+surf_callback(void, Host*, e_surf_resource_state_t, e_surf_resource_state_t) hostStateChangedCallbacks;
+surf_callback(void, HostAction*, e_surf_action_state_t, e_surf_action_state_t) hostActionStateChangedCallbacks;
void host_parse_init(sg_platf_host_cbarg_t host)
{
/*********
* Model *
*********/
-HostModel::HostModel(const char *name)
- : Model(name)
-{
- p_cpuModel = surf_cpu_model_pm;
-}
-
-HostModel::HostModel()
-: Model("Host") {
- p_cpuModel = surf_cpu_model_pm;
-}
-
-HostModel::~HostModel() {
-}
-
/* Each VM has a dummy CPU action on the PM layer. This CPU action works as the
* constraint (capacity) of the VM in the PM layer. If the VM does not have any
* active task, the dummy CPU action must be deactivated, so that the VM does
VMModel::ws_vms.begin();
iter != VMModel::ws_vms.end(); ++iter) {
- VMPtr ws_vm = &*iter;
- CpuCas01Ptr cpu_cas01 = static_cast<CpuCas01Ptr>(ws_vm->p_cpu);
+ VirtualMachine *ws_vm = &*iter;
+ CpuCas01 *cpu_cas01 = static_cast<CpuCas01*>(ws_vm->p_cpu);
xbt_assert(cpu_cas01, "cpu-less host");
int is_active = lmm_constraint_used(cpu_cas01->getModel()->getMaxminSystem(), cpu_cas01->getConstraint());
// int is_active_old = constraint_is_active(cpu_cas01);
- // {
- // xbt_assert(is_active == is_active_old, "%d %d", is_active, is_active_old);
- // }
-
if (is_active) {
/* some tasks exist on this VM */
XBT_DEBUG("set the weight of the dummy CPU action on PM to 1");
- /* FIXME: we shoud use lmm_update_variable_weight() ? */
- /* FIXME: If we assgign 1.05 and 0.05, the system makes apparently wrong values. */
+ /* FIXME: we should use lmm_update_variable_weight() ? */
+ /* FIXME: If we assign 1.05 and 0.05, the system makes apparently wrong values. */
ws_vm->p_action->setPriority(1);
} else {
/************
* Resource *
************/
-Host::Host()
-{
- surf_callback_emit(hostCreatedCallbacks, this);
-}
-
-Host::Host(ModelPtr model, const char *name, xbt_dict_t props,
- xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu)
+Host::Host(Model *model, const char *name, xbt_dict_t props,
+ xbt_dynar_t storage, RoutingEdge *netElm, Cpu *cpu)
: Resource(model, name, props)
, p_storage(storage), p_netElm(netElm), p_cpu(cpu)
{
p_params.ramsize = 0;
- surf_callback_emit(hostCreatedCallbacks, this);
}
-Host::Host(ModelPtr model, const char *name, xbt_dict_t props, lmm_constraint_t constraint,
- xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu)
+Host::Host(Model *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint,
+ xbt_dynar_t storage, RoutingEdge *netElm, Cpu *cpu)
: Resource(model, name, props, constraint)
, p_storage(storage), p_netElm(netElm), p_cpu(cpu)
{
p_params.ramsize = 0;
- surf_callback_emit(hostCreatedCallbacks, this);
}
Host::~Host(){
p_cpu->setState(state);
}
-int Host::getCore(){
- return p_cpu->getCore();
-}
-
-double Host::getSpeed(double load){
- return p_cpu->getSpeed(load);
-}
-
-double Host::getAvailableSpeed(){
- return p_cpu->getAvailableSpeed();
-}
-
-double Host::getCurrentPowerPeak()
-{
- return p_cpu->getCurrentPowerPeak();
-}
-
-double Host::getPowerPeakAt(int pstate_index)
-{
- return p_cpu->getPowerPeakAt(pstate_index);
-}
-
-int Host::getNbPstates()
-{
- return p_cpu->getNbPstates();
-}
-
-void Host::setPstate(int pstate_index)
-{
- p_cpu->setPstate(pstate_index);
-}
-int Host::getPstate()
-{
- return p_cpu->getPstate();
-}
-
xbt_dict_t Host::getProperties()
{
return p_cpu->getProperties();
}
-StoragePtr Host::findStorageOnMountList(const char* mount)
+Storage *Host::findStorageOnMountList(const char* mount)
{
- StoragePtr st = NULL;
+ Storage *st = NULL;
s_mount_t mnt;
unsigned int cursor;
{
XBT_DEBUG("See '%s'",mnt.name);
if(!strcmp(mount,mnt.name)){
- st = static_cast<StoragePtr>(mnt.storage);
+ st = static_cast<Storage*>(mnt.storage);
break;
}
}
char *storage_name = NULL;
xbt_dynar_foreach(p_storage,i,mnt){
- storage_name = (char *)static_cast<StoragePtr>(mnt.storage)->getName();
+ storage_name = (char *)static_cast<Storage*>(mnt.storage)->getName();
xbt_dict_set(storage_list,mnt.name,storage_name,NULL);
}
return storage_list;
xbt_dynar_t result = xbt_dynar_new(sizeof(void*), NULL);
xbt_lib_foreach(storage_lib, cursor, key, data) {
if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != NULL) {
- StoragePtr storage = static_cast<StoragePtr>(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL));
+ Storage *storage = static_cast<Storage*>(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL));
if(!strcmp((const char*)storage->p_attach,this->getName())){
xbt_dynar_push_as(result, void *, (void*)storage->getName());
}
return result;
}
-ActionPtr Host::open(const char* fullpath) {
+Action *Host::open(const char* fullpath) {
- StoragePtr st = NULL;
+ Storage *st = NULL;
s_mount_t mnt;
unsigned int cursor;
size_t longest_prefix_length = 0;
if(!strcmp(file_mount_name,mnt.name) && strlen(mnt.name)>longest_prefix_length)
{/* The current mount name is found in the full path and is bigger than the previous*/
longest_prefix_length = strlen(mnt.name);
- st = static_cast<StoragePtr>(mnt.storage);
+ st = static_cast<Storage*>(mnt.storage);
}
free(file_mount_name);
}
xbt_die("Can't find mount point for '%s' on '%s'", fullpath, getName());
XBT_DEBUG("OPEN %s on disk '%s'",path, st->getName());
- ActionPtr action = st->open((const char*)mount_name, (const char*)path);
+ Action *action = st->open((const char*)mount_name, (const char*)path);
free((char*)path);
free((char*)mount_name);
return action;
}
-ActionPtr Host::close(surf_file_t fd) {
- StoragePtr st = findStorageOnMountList(fd->mount);
+Action *Host::close(surf_file_t fd) {
+ Storage *st = findStorageOnMountList(fd->mount);
XBT_DEBUG("CLOSE %s on disk '%s'",fd->name, st->getName());
return st->close(fd);
}
-ActionPtr Host::read(surf_file_t fd, sg_size_t size) {
- StoragePtr st = findStorageOnMountList(fd->mount);
+Action *Host::read(surf_file_t fd, sg_size_t size) {
+ Storage *st = findStorageOnMountList(fd->mount);
XBT_DEBUG("READ %s on disk '%s'",fd->name, st->getName());
return st->read(fd, size);
}
-ActionPtr Host::write(surf_file_t fd, sg_size_t size) {
- StoragePtr st = findStorageOnMountList(fd->mount);
+Action *Host::write(surf_file_t fd, sg_size_t size) {
+ Storage *st = findStorageOnMountList(fd->mount);
XBT_DEBUG("WRITE %s on disk '%s'",fd->name, st->getName());
return st->write(fd, size);
}
return -1;
} else {
- StoragePtr st = findStorageOnMountList(fd->mount);
+ Storage *st = findStorageOnMountList(fd->mount);
/* Check if the file is on this storage */
if (!xbt_dict_get_or_null(st->p_content, fd->name)){
XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->name,
xbt_dynar_t Host::getInfo( surf_file_t fd)
{
- StoragePtr st = findStorageOnMountList(fd->mount);
+ Storage *st = findStorageOnMountList(fd->mount);
sg_size_t *psize = xbt_new(sg_size_t, 1);
*psize = fd->size;
xbt_dynar_t info = xbt_dynar_new(sizeof(void*), NULL);
xbt_dynar_t Host::getVms()
{
- xbt_dynar_t dyn = xbt_dynar_new(sizeof(VMPtr), NULL);
+ xbt_dynar_t dyn = xbt_dynar_new(sizeof(VirtualMachine*), NULL);
/* iterate for all virtual machines */
for (VMModel::vm_list_t::iterator iter =
VMModel::ws_vms.begin();
iter != VMModel::ws_vms.end(); ++iter) {
- VMPtr ws_vm = &*iter;
+ VirtualMachine *ws_vm = &*iter;
if (this == ws_vm->p_subWs)
xbt_dynar_push(dyn, &ws_vm);
}
return dyn;
}
-void Host::getParams(ws_params_t params)
+void Host::getParams(vm_params_t params)
{
*params = p_params;
}
-void Host::setParams(ws_params_t params)
+void Host::setParams(vm_params_t params)
{
/* may check something here. */
p_params = *params;