src/include/surf/maxmin.h
src/include/surf/random_mgr.h
src/include/surf/surf.h
- src/include/surf/surf_resource.h
- src/include/surf/surf_resource_lmm.h
src/include/surf/surfxml_parse_values.h
src/include/surf/trace_mgr.h
src/include/xbt/win32_ucontext.h
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
+++ /dev/null
-
-/* Copyright (c) 2009-2014. The SimGrid Team.
- * All rights reserved. */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include "surf/surf.h"
-#ifndef SURF_RESOURCE_H
-#define SURF_RESOURCE_H
-
-/*FIXME:DELETEstatic XBT_INLINE
- surf_resource_t surf_resource_new(size_t childsize,
- surf_model_t model, const char *name,
- xbt_dict_t props, void_f_pvoid_t free_f)
-{
- surf_resource_t res = xbt_malloc0(childsize);
- res->model = model;
- res->name = xbt_strdup(name);
- res->properties = props;
- res->free_f=free_f;
- return res;
-}
-
-static XBT_INLINE void surf_resource_free(void *r)
-{
- surf_resource_t resource = r;
- if(resource->free_f)
- resource->free_f(r);
- free(resource->name);
- xbt_dict_free(&resource->properties);
- free(resource);
-}
-
-static XBT_INLINE const char *surf_resource_name(const void *resource)
-{
- return ((surf_resource_t) resource)->name;
-}
-
-static XBT_INLINE xbt_dict_t surf_resource_properties(const void *resource)
-{
- return ((surf_resource_t) resource)->properties;
-}*/
-
-#endif /* SURF_RESOURCE_H */
+++ /dev/null
-
-/* Copyright (c) 2009-2014. The SimGrid Team.
- * All rights reserved. */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#ifndef SURF_RESOURCE_LMM_H
-#define SURF_RESOURCE_LMM_H
-#include "surf/surf.h"
-#include "surf/trace_mgr.h"
-#include "surf/surf_resource.h"
-
-#ifdef TOMATO
-static XBT_INLINE
- surf_resource_lmm_t surf_resource_lmm_new(size_t childsize,
- /* for superclass */
- surf_model_t model,
- const char *name, xbt_dict_t props,
- lmm_system_t system,
- double constraint_value,
- tmgr_history_t history,
- e_surf_resource_state_t state_init,
- tmgr_trace_t state_trace,
- double metric_peak,
- tmgr_trace_t metric_trace)
-{
-
- surf_resource_lmm_t res =
- (surf_resource_lmm_t) surf_resource_new(childsize, model, name,
- props, NULL);
-
- res->constraint = lmm_constraint_new(system, res, constraint_value);
- res->state_current = state_init;
- if (state_trace)
- res->state_event =
- tmgr_history_add_trace(history, state_trace, 0.0, 0, res);
-
- res->power.scale = 1.0;
- res->power.peak = metric_peak;
- if (metric_trace)
- res->power.event =
- tmgr_history_add_trace(history, metric_trace, 0.0, 0, res);
- return res;
-}
-#endif
-
-static XBT_INLINE e_surf_resource_state_t surf_resource_lmm_get_state(void
- *r)
-{
- surf_resource_lmm_t resource = (surf_resource_lmm_t) r;
- return (resource)->state_current;
-}
-#endif /* SURF_RESOURCE_LMM_H */
#include "xbt/dict.h"
#include "xbt/sysdep.h"
#include "surf/surf.h"
-#include "surf/surf_resource.h"
/* Creates a link and registers it in SD.
#include "xbt/lib.h"
#include "xbt/sysdep.h"
#include "surf/surf.h"
-#include "surf/surf_resource.h"
#include "simgrid/msg.h" //FIXME: why?
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_workstation, sd,
*/
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);
}
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)
: Resource(model, name, props)
*/
class Host : public Resource {
public:
- /**
- * @brief Host constructor
- */
- Host();
-
/**
* @brief Host constructor
*
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"