class StorageModel;
class Resource;
class ResourceLmm;
+class Host;
class HostCLM03;
class NetworkCm02Link;
class Cpu;
typedef struct Resource Resource;
typedef struct ResourceLmm ResourceLmm;
typedef struct HostCLM03 HostCLM03;
+typedef struct Host Host;
typedef struct NetworkCm02Link NetworkCm02Link;
typedef struct Cpu Cpu;
typedef struct Action Action;
typedef xbt_dictelm_t surf_resource_t;
typedef Resource *surf_cpp_resource_t;
+typedef Host *surf_host_t;
typedef HostCLM03 *surf_host_CLM03_t;
typedef NetworkCm02Link *surf_network_link_t;
typedef Cpu *surf_cpu_t;
/* Generic model object */
/***************************/
-//FIXME:REMOVE typedef struct s_routing_platf s_routing_platf_t, *routing_platf_t;
XBT_PUBLIC_DATA(routing_platf_t) routing_platf;
-static inline void *surf_cpu_resource_priv(const void *host) {
- return xbt_lib_get_level((xbt_dictelm_t)host, SURF_CPU_LEVEL);
+static inline surf_cpu_t surf_cpu_resource_priv(const void *host) {
+ return (surf_cpu_t)xbt_lib_get_level((xbt_dictelm_t)host, SURF_CPU_LEVEL);
}
-static inline void *surf_host_resource_priv(const void *host){
- return (void*)xbt_lib_get_level((xbt_dictelm_t)host, SURF_HOST_LEVEL);
+static inline surf_host_t surf_host_resource_priv(const void *host){
+ return (surf_host_t) xbt_lib_get_level((xbt_dictelm_t)host, SURF_HOST_LEVEL);
}
static inline void *surf_routing_resource_priv(const void *host){
return (void*)xbt_lib_get_level((xbt_dictelm_t)host, ROUTING_HOST_LEVEL);
* @return The name of the surf resource
*/
XBT_PUBLIC(const char * ) surf_resource_name(surf_cpp_resource_t resource);
+static inline const char * surf_cpu_name(surf_cpu_t cpu) {
+ return surf_resource_name((surf_cpp_resource_t)cpu);
+}
/**
* @brief Get the properties of a surf resource (cpu, host, network, …)
* @return The properties of the surf resource
*/
XBT_PUBLIC(xbt_dict_t) surf_resource_get_properties(surf_cpp_resource_t resource);
+static XBT_INLINE xbt_dict_t surf_host_get_properties(surf_host_t host) {
+ return surf_resource_get_properties((surf_cpp_resource_t)host);
+}
+
/**
* @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, …)
*
* @param state The new state of the surf resource
*/
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) {
+ surf_resource_set_state((surf_cpp_resource_t)host, state);
+}
/**
* @brief Get the speed of the cpu associated to a host
*/
xbt_dict_t SD_workstation_get_properties(SD_workstation_t workstation)
{
- return surf_resource_get_properties(surf_host_resource_priv(workstation));
+ return surf_host_get_properties(surf_host_resource_priv(workstation));
}
xbt_assert((host != NULL), "Invalid parameters");
- if (surf_resource_get_state(surf_host_resource_priv(h))==SURF_RESOURCE_OFF) {
- surf_resource_set_state(surf_host_resource_priv(h), SURF_RESOURCE_ON);
+ if (surf_host_get_state(surf_host_resource_priv(h))==SURF_RESOURCE_OFF) {
+ surf_host_set_state(surf_host_resource_priv(h), SURF_RESOURCE_ON);
unsigned int cpt;
smx_process_arg_t arg;
xbt_assert((host != NULL), "Invalid parameters");
- if (surf_resource_get_state(surf_host_resource_priv(h))==SURF_RESOURCE_ON) {
- surf_resource_set_state(surf_host_resource_priv(h), SURF_RESOURCE_OFF);
+ if (surf_host_get_state(surf_host_resource_priv(h))==SURF_RESOURCE_ON) {
+ surf_host_set_state(surf_host_resource_priv(h), SURF_RESOURCE_OFF);
/* Clean Simulator data */
if (xbt_swag_size(host->process_list) != 0) {
}
xbt_dict_t SIMIX_host_get_properties(smx_host_t host){
- return surf_resource_get_properties(surf_host_resource_priv(host));
+ return surf_host_get_properties(surf_host_resource_priv(host));
}
double SIMIX_host_get_speed(smx_host_t host){
}
int SIMIX_host_get_state(smx_host_t host){
- return surf_resource_get_state(surf_host_resource_priv(host));
+ return surf_host_get_state(surf_host_resource_priv(host));
}
void _SIMIX_host_free_process_arg(void *data)
(int)synchro->state);
}
/* check if the host is down */
- if (surf_resource_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
+ if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
simcall->issuer->context->iwannadie = 1;
}
{
if (synchro->type == SIMIX_SYNC_EXECUTE && /* FIMXE: handle resource failure
* for parallel tasks too */
- surf_resource_get_state(surf_host_resource_priv(synchro->execution.host)) == SURF_RESOURCE_OFF) {
+ surf_host_get_state(surf_host_resource_priv(synchro->execution.host)) == 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_resource_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+ if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_name(host));
}
smx_synchro_t synchro;
/* check if the host is active */
- if (surf_resource_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+ if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_name(host));
}
smx_synchro_t synchro;
/* check if the host is active */
- if (surf_resource_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+ if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_name(host));
}
smx_synchro_t synchro;
/* check if the host is active */
- if (surf_resource_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+ if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_name(host));
}
int SIMIX_file_unlink(smx_file_t fd, smx_host_t host)
{
/* check if the host is active */
- if (surf_resource_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+ if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_name(host));
}
(int)synchro->state);
}
- if (surf_resource_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
+ if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
simcall->issuer->context->iwannadie = 1;
}
/* Check out for errors */
- if (surf_resource_get_state(surf_host_resource_priv(
+ if (surf_host_get_state(surf_host_resource_priv(
simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
simcall->issuer->context->iwannadie = 1;
SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
}
}
- if (surf_resource_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
+ if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
simcall->issuer->context->iwannadie = 1;
}
smx_host_t host = process->smx_host;
/* check if the host is active */
- if (surf_resource_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
+ if (surf_host_get_state(surf_host_resource_priv(host)) != SURF_RESOURCE_ON) {
THROWF(host_error, 0, "Host %s failed, you cannot call this function",
sg_host_name(host));
}
THROW_IMPOSSIBLE;
break;
}
- if (surf_resource_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
+ if (surf_host_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
simcall->issuer->context->iwannadie = 1;
}
simcall_process_sleep__set__result(simcall, state);
void SIMIX_vm_start(smx_host_t ind_vm)
{
if (__can_be_started(ind_vm))
- surf_resource_set_state(surf_host_resource_priv(ind_vm),
+ surf_host_set_state(surf_host_resource_priv(ind_vm),
(int)SURF_VM_STATE_RUNNING);
else
THROWF(vm_error, 0, "The VM %s cannot be started", SIMIX_host_get_name(ind_vm));
int SIMIX_vm_get_state(smx_host_t ind_vm)
{
- return surf_resource_get_state(surf_host_resource_priv(ind_vm));
+ return surf_host_get_state(surf_host_resource_priv(ind_vm));
}
/**
}
/* FIXME: we may have to do something at the surf layer, e.g., vcpu action */
- surf_resource_set_state(surf_host_resource_priv(ind_vm),
+ surf_host_set_state(surf_host_resource_priv(ind_vm),
(int)SURF_VM_STATE_CREATED);
}
class Storage;
typedef Storage *StoragePtr;
-class Storage;
-typedef Storage *StoragePtr;
-
-class StorageAction;
-typedef StorageAction *StorageActionPtr;
-
class StorageAction;
typedef StorageAction *StorageActionPtr;
#include <stdio.h>
#include "simgrid/sg_config.h"
#include "surf/surf.h"
-#include "surf/surf_resource.h"
#include "surf/surfxml_parse.h" // for reset callback
#include "xbt/log.h"
cpuB = surf_cpu_resource_by_name("Cpu B");
/* Let's check that those two processors exist */
- XBT_DEBUG("%s : %p", surf_resource_name(surf_cpu_resource_priv(cpuA)), cpuA);
- XBT_DEBUG("%s : %p", surf_resource_name(surf_cpu_resource_priv(cpuB)), cpuB);
+ XBT_DEBUG("%s : %p", surf_cpu_name(surf_cpu_resource_priv(cpuA)), cpuA);
+ XBT_DEBUG("%s : %p", surf_cpu_name(surf_cpu_resource_priv(cpuB)), cpuB);
/* Let's do something on it */
actionA = surf_cpu_execute(cpuA, 1000.0);
#include <stdio.h>
#include "simgrid/sg_config.h"
#include "surf/surf.h"
-#include "surf/surf_resource.h"
#include "surf/surfxml_parse.h" // for reset callback
#include "xbt/log.h"