simgrid::xbt::string const& getName() const { return name_; }
void on();
void off();
+ e_surf_resource_state_t getState();
xbt_dict_t getProperties();
xbt_swag_t getProcessList();
double getCurrentPowerPeak();
/** @brief Get the state of a surf resource (cpu, host, network, …) */
XBT_PUBLIC(e_surf_resource_state_t) surf_resource_get_state(surf_cpp_resource_t resource);
-static XBT_INLINE e_surf_resource_state_t surf_host_get_state(surf_host_t host) {
- return surf_resource_get_state((surf_cpp_resource_t)host);
-}
-
-
/** @brief Set the state of a surf resource (cpu, host, network, …) */
XBT_PUBLIC(void) surf_resource_set_state(surf_cpp_resource_t resource, e_surf_resource_state_t state);
static inline void surf_host_set_state(surf_host_t host, e_surf_resource_state_t state) {
* @return 1 if the host is active or 0 if it has crashed.
*/
int sg_host_get_state(sg_host_t host) {
- return surf_host_get_state(surf_host_resource_priv(host));
+ return host->p_cpu->getState();
}
/** @brief Returns the total energy consumed by the host (in Joules).
simgrid::simix::simcall<void>(SIMCALL_HOST_OFF, this);
}
+e_surf_resource_state_t Host::getState() {
+ return p_cpu->getState();
+}
+
+
/** Get the properties assigned to a host */
xbt_dict_t Host::getProperties()
{
xbt_assert((host != NULL), "Invalid parameters");
- if (surf_host_get_state(surf_host_resource_priv(h))==SURF_RESOURCE_OFF) {
+ if (h->getState()==SURF_RESOURCE_OFF) {
surf_host_set_state(surf_host_resource_priv(h), SURF_RESOURCE_ON);
unsigned int cpt;
xbt_assert((host != NULL), "Invalid parameters");
- if (surf_host_get_state(surf_host_resource_priv(h))==SURF_RESOURCE_ON) {
+ if (h->getState()==SURF_RESOURCE_ON) {
surf_host_set_state(surf_host_resource_priv(h), SURF_RESOURCE_OFF);
/* Clean Simulator data */
(int)synchro->state);
}
/* check if the host is down */
- if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->host)) != SURF_RESOURCE_ON) {
+ if (simcall->issuer->host->getState() != SURF_RESOURCE_ON) {
simcall->issuer->context->iwannadie = 1;
}
{
if (synchro->type == SIMIX_SYNC_EXECUTE && /* FIMXE: handle resource failure
* for parallel tasks too */
- surf_host_get_state(surf_host_resource_priv(synchro->execution.host)) == SURF_RESOURCE_OFF) {
+ synchro->execution.host->getState() == SURF_RESOURCE_OFF) {
/* If the host running the synchro failed, notice it so that the asking
* process can be killed if it runs on that host itself */
synchro->state = SIMIX_FAILED;
smx_synchro_t synchro;
/* check if the host is active */
- if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+ if (host->getState() != SURF_RESOURCE_ON) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_get_name(host));
}
smx_synchro_t synchro;
/* check if the host is active */
- if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+ if (host->getState() != SURF_RESOURCE_ON) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_get_name(host));
}
smx_synchro_t synchro;
/* check if the host is active */
- if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+ if (host->getState() != SURF_RESOURCE_ON) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_get_name(host));
}
smx_synchro_t synchro;
/* check if the host is active */
- if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+ if (host->getState() != SURF_RESOURCE_ON) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_get_name(host));
}
int SIMIX_file_unlink(smx_file_t fd, sg_host_t host)
{
/* check if the host is active */
- if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+ if (host->getState() != SURF_RESOURCE_ON) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_get_name(host));
}
(int)synchro->state);
}
- if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->host)) != SURF_RESOURCE_ON) {
+ if (simcall->issuer->host->getState() != SURF_RESOURCE_ON) {
simcall->issuer->context->iwannadie = 1;
}
/* Check out for errors */
- if (surf_host_get_state(surf_host_resource_priv(
- simcall->issuer->host)) != SURF_RESOURCE_ON) {
+ if (simcall->issuer->host->getState() != SURF_RESOURCE_ON) {
simcall->issuer->context->iwannadie = 1;
SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
} else
}
}
- if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->host)) != SURF_RESOURCE_ON) {
+ if (simcall->issuer->host->getState() != SURF_RESOURCE_ON) {
simcall->issuer->context->iwannadie = 1;
}
sg_host_t host = process->host;
/* check if the host is active */
- if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+ if (host->getState() != SURF_RESOURCE_ON) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_get_name(host));
}
THROW_IMPOSSIBLE;
break;
}
- if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->host)) != SURF_RESOURCE_ON) {
+ if (simcall->issuer->host->getState() != SURF_RESOURCE_ON) {
simcall->issuer->context->iwannadie = 1;
}
simcall_process_sleep__set__result(simcall, state);
#include "xbt/log.h"
#include "xbt/dict.h"
#include "mc/mc.h"
+#include "src/surf/host_interface.hpp"
//If you need to log some stuffs, just uncomment these two lines and uses XBT_DEBUG for instance
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix, "Logging specific to SIMIX (vms)");
int SIMIX_vm_get_state(sg_host_t ind_vm)
{
- return surf_host_get_state(surf_host_resource_priv(ind_vm));
+ return surf_host_resource_priv(ind_vm)->getState();
}
/**
/** @brief Destructor */
~VirtualMachine();
- void setState(e_surf_resource_state_t state);
+ void setState(e_surf_resource_state_t state) override;
/** @brief Suspend the VM */
virtual void suspend()=0;
void migrate(sg_host_t ind_dst_pm) override;
- e_surf_resource_state_t getState();
- void setState(e_surf_resource_state_t state);
+ e_surf_resource_state_t getState() override;
+ void setState(e_surf_resource_state_t state) override;
void setBound(double bound);
void setAffinity(Cpu *cpu, unsigned long mask);