src/surf/simgrid_dtd.c
src/surf/simgrid.dtd
src/surf/network_private.h
+ src/surf/storage_private.h
src/surf/network_gtnets_private.h
src/surf/gtnets/gtnets_interface.h
src/surf/gtnets/gtnets_simulator.h
include/xbt/automaton.h
include/xbt/automatonparse_promela.h
include/xbt/datadesc.h
+ include/xbt/socket.h
include/simgrid/platf.h
include/simgrid/modelchecker.h
include/msg/msg.h
int host(int argc, char *argv[])
{
m_file_t file;
- file = MSG_file_open("test.txt","rw");
+ char* mount = bprintf("C:");
+
+ file = MSG_file_open(mount,"test.txt","rw");
XBT_INFO("Host '%s' open %p",MSG_host_get_name(MSG_host_self()), file);
- size_t read = MSG_file_read(NULL,0,0,file);
+ size_t read = MSG_file_read(mount,NULL,0,0,file);
XBT_INFO("Host '%s' read %zu", MSG_host_get_name(MSG_host_self()), read);
- size_t write = MSG_file_write(NULL,0,0,file);
+ size_t write = MSG_file_write(mount,NULL,0,0,file);
XBT_INFO("Host '%s' write %zu", MSG_host_get_name(MSG_host_self()), write);
- int res = MSG_file_stat(0,NULL);
+ int res = MSG_file_stat(mount,0,NULL);
XBT_INFO("Host '%s' stat %d",MSG_host_get_name(MSG_host_self()), res);
- res = MSG_file_close(file);
+ res = MSG_file_close(mount,file);
XBT_INFO("Host '%s' close %d",MSG_host_get_name(MSG_host_self()), res);
+
+ free(mount);
return 0;
}
</host>
<host id="alice" power="1000000000">
- <mstorage typeId="crucial" name="C:"/>
+ <mount id="Disk1" name="C:"/>
</host>
<storage id="Disk4" typeId="wdigital"/>
/************************** File handling ***********************************/
-XBT_PUBLIC(size_t) MSG_file_read(void* ptr, size_t size, size_t nmemb, m_file_t stream);
-XBT_PUBLIC(size_t) MSG_file_write(const void* ptr, size_t size, size_t nmemb, m_file_t stream);
-XBT_PUBLIC(m_file_t) MSG_file_open(const char* path, const char* mode);
-XBT_PUBLIC(int) MSG_file_close(m_file_t fp);
-XBT_PUBLIC(int) MSG_file_stat(int fd, void* buf);
+XBT_PUBLIC(size_t) MSG_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, m_file_t stream);
+XBT_PUBLIC(size_t) MSG_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, m_file_t stream);
+XBT_PUBLIC(m_file_t) MSG_file_open(const char* storage, const char* path, const char* mode);
+XBT_PUBLIC(int) MSG_file_close(const char* storage, m_file_t fp);
+XBT_PUBLIC(int) MSG_file_stat(const char* storage, int fd, void* buf);
/************************** Host handling ***********************************/
} s_sg_platf_cluster_cbarg_t;
typedef struct {
- char* id;
- char* type_id;
+ const char* id;
+ const char* type_id;
} s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
typedef struct {
- char* id;
- char* model;
- char* content;
+ const char* id;
+ const char* model;
+ const char* content;
xbt_dict_t properties;
} s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
typedef struct {
- char* type_id;
- char* name;
+ const char* type_id;
+ const char* name;
} s_sg_platf_mstorage_cbarg_t, *sg_platf_mstorage_cbarg_t;
typedef struct {
XBT_PUBLIC(unsigned int) simcall_sem_acquire_any(xbt_dynar_t sems);
XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
-XBT_PUBLIC(size_t) simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream);
-XBT_PUBLIC(size_t) simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
-XBT_PUBLIC(smx_file_t) simcall_file_open(const char* path, const char* mode);
-XBT_PUBLIC(int) simcall_file_close(smx_file_t fp);
-XBT_PUBLIC(int) simcall_file_stat(int fd, void* buf);
+XBT_PUBLIC(size_t) simcall_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, smx_file_t stream);
+XBT_PUBLIC(size_t) simcall_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
+XBT_PUBLIC(smx_file_t) simcall_file_open(const char* storage, const char* path, const char* mode);
+XBT_PUBLIC(int) simcall_file_close(const char* storage, smx_file_t fp);
+XBT_PUBLIC(int) simcall_file_stat(const char* storage, int fd, void* buf);
SG_END_DECL()
#endif /* _SIMIX_SIMIX_H */
extern xbt_lib_t storage_lib;
extern int ROUTING_STORAGE_LEVEL; //Routing storage level
-extern int ROUTING_STORAGE_TYPE_LEVEL; //Routing storage_type level
extern int ROUTING_STORAGE_HOST_LEVEL;
+extern int SURF_STORAGE_LEVEL;
+
+extern xbt_lib_t storage_type_lib;
+extern int ROUTING_STORAGE_TYPE_LEVEL; //Routing storage_type level
/* The callbacks to register for the routing to work */
void routing_AS_begin(const char *AS_id, const char *wanted_routing_type);
*/
typedef struct surf_storage_model_extension_public {
- surf_action_t(*open) (void *workstation, const char* path, const char* mode);
- surf_action_t(*close) (void *workstation, surf_file_t fp);
- surf_action_t(*read) (void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
- surf_action_t(*write) (void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
- surf_action_t(*stat) (void *workstation, int fd, void* buf);
- void* (*create_resource) (const char* id, const char* model,
- const char* content, xbt_dict_t properties);
+ surf_action_t(*open) (void *storage, const char* path, const char* mode);
+ surf_action_t(*close) (void *storage, surf_file_t fp);
+ surf_action_t(*read) (void *storage, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
+ surf_action_t(*write) (void *storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
+ surf_action_t(*stat) (void *storage, int fd, void* buf);
+ void* (*create_resource) (const char* id, const char* model,const char* type_id,
+ const char* content, xbt_dict_t storage_properties);
} s_surf_model_extension_storage_t;
/** \brief Workstation model extension public
double amount, double rate);
double (*get_link_bandwidth) (const void *link); /**< Return the current bandwidth of a network link */
double (*get_link_latency) (const void *link); /**< Return the current latency of a network link */
- surf_action_t(*open) (void *workstation, const char* path, const char* mode);
- surf_action_t(*close) (void *workstation, surf_file_t fp);
- surf_action_t(*read) (void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
- surf_action_t(*write) (void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
- surf_action_t(*stat) (void *workstation, int fd, void* buf);
+ surf_action_t(*open) (void *workstation, const char* storage, const char* path, const char* mode);
+ surf_action_t(*close) (void *workstation, const char* storage, surf_file_t fp);
+ surf_action_t(*read) (void *workstation, const char* storage, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
+ surf_action_t(*write) (void *workstation, const char* storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
+ surf_action_t(*stat) (void *workstation, const char* storage, int fd, void* buf);
int (*link_shared) (const void *link);
xbt_dict_t(*get_properties) (const void *resource);
void* (*link_create_resource) (const char *name,
static inline void *surf_network_resource_by_name(const char *name){
return xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL);
}
+static inline void *surf_storage_resource_by_name(const char *name){
+ return xbt_lib_get_or_null(storage_lib, name, SURF_STORAGE_LEVEL);
+}
typedef struct surf_resource {
surf_model_t model;
typedef struct s_storage_type {
char *model;
char *content;
- xbt_dict_t properties;
char *type_id;
+ xbt_dict_t properties;
} s_storage_type_t, *storage_type_t;
typedef struct s_mount {
- char *type_id;
+ char *id;
char *name;
} s_mount_t, *mount_t;
// FILE
-size_t MSG_file_read(void* ptr, size_t size, size_t nmemb, m_file_t stream)
+size_t MSG_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, m_file_t stream)
{
- return simcall_file_read(ptr, size, nmemb, (smx_file_t)stream);
+ return simcall_file_read(storage, ptr, size, nmemb, (smx_file_t)stream);
}
-size_t MSG_file_write(const void* ptr, size_t size, size_t nmemb, m_file_t stream)
+size_t MSG_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, m_file_t stream)
{
- return simcall_file_write(ptr, size, nmemb, (smx_file_t)stream);
+ return simcall_file_write(storage, ptr, size, nmemb, (smx_file_t)stream);
}
-m_file_t MSG_file_open(const char* path, const char* mode)
+m_file_t MSG_file_open(const char* storage, const char* path, const char* mode)
{
- return (m_file_t) simcall_file_open(path, mode);
+ return (m_file_t) simcall_file_open(storage, path, mode);
}
-int MSG_file_close(m_file_t fp)
+int MSG_file_close(const char* storage, m_file_t fp)
{
- return simcall_file_close((smx_file_t)fp);
+ return simcall_file_close(storage, (smx_file_t)fp);
}
-int MSG_file_stat(int fd, void* buf)
+int MSG_file_stat(const char* storage, int fd, void* buf)
{
- return simcall_file_stat(fd, buf);
+ return simcall_file_stat(storage, fd, buf);
}
void SIMIX_pre_file_read(smx_simcall_t simcall)
{
smx_action_t action = SIMIX_file_read(simcall->issuer,
+ simcall->file_read.storage,
simcall->file_read.ptr,
simcall->file_read.size,
simcall->file_read.nmemb,
simcall->issuer->waiting_action = action;
}
-smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+smx_action_t SIMIX_file_read(smx_process_t process, const char* storage, void* ptr, size_t size, size_t nmemb, smx_file_t stream)
{
smx_action_t action;
smx_host_t host = process->smx_host;
#endif
action->io.host = host;
- action->io.surf_io = surf_workstation_model->extension.workstation.read(host->host, ptr, size, nmemb, (surf_file_t)stream),
+ action->io.surf_io = surf_workstation_model->extension.workstation.read(host->host, storage, ptr, size, nmemb, (surf_file_t)stream),
surf_workstation_model->action_data_set(action->io.surf_io, action);
XBT_DEBUG("Create io action %p", action);
void SIMIX_pre_file_write(smx_simcall_t simcall)
{
smx_action_t action = SIMIX_file_write(simcall->issuer,
+ simcall->file_write.storage,
simcall->file_write.ptr,
simcall->file_write.size,
simcall->file_write.nmemb,
simcall->issuer->waiting_action = action;
}
-smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+smx_action_t SIMIX_file_write(smx_process_t process, const char* storage, const void* ptr, size_t size, size_t nmemb, smx_file_t stream)
{
smx_action_t action;
smx_host_t host = process->smx_host;
#endif
action->io.host = host;
- action->io.surf_io = surf_workstation_model->extension.workstation.write(host->host, ptr, size, nmemb, (surf_file_t)stream);
+ action->io.surf_io = surf_workstation_model->extension.workstation.write(host->host, storage, ptr, size, nmemb, (surf_file_t)stream);
surf_workstation_model->action_data_set(action->io.surf_io, action);
XBT_DEBUG("Create io action %p", action);
void SIMIX_pre_file_open(smx_simcall_t simcall)
{
smx_action_t action = SIMIX_file_open(simcall->issuer,
+ simcall->file_open.storage,
simcall->file_open.path,
simcall->file_open.mode);
xbt_fifo_push(action->simcalls, simcall);
simcall->issuer->waiting_action = action;
}
-smx_action_t SIMIX_file_open(smx_process_t process, const char* path, const char* mode)
+smx_action_t SIMIX_file_open(smx_process_t process ,const char* storage, const char* path, const char* mode)
{
smx_action_t action;
smx_host_t host = process->smx_host;
#endif
action->io.host = host;
- action->io.surf_io = surf_workstation_model->extension.workstation.open(host->host, path, mode);
+ action->io.surf_io = surf_workstation_model->extension.workstation.open(host->host, storage, path, mode);
surf_workstation_model->action_data_set(action->io.surf_io, action);
XBT_DEBUG("Create io action %p", action);
void SIMIX_pre_file_close(smx_simcall_t simcall)
{
smx_action_t action = SIMIX_file_close(simcall->issuer,
+ simcall->file_close.storage,
simcall->file_close.fp);
xbt_fifo_push(action->simcalls, simcall);
simcall->issuer->waiting_action = action;
}
-smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fp)
+smx_action_t SIMIX_file_close(smx_process_t process ,const char* storage, smx_file_t fp)
{
smx_action_t action;
smx_host_t host = process->smx_host;
#endif
action->io.host = host;
- action->io.surf_io = surf_workstation_model->extension.workstation.close(host->host, (surf_file_t)fp);
+ action->io.surf_io = surf_workstation_model->extension.workstation.close(host->host, storage, (surf_file_t)fp);
surf_workstation_model->action_data_set(action->io.surf_io, action);
XBT_DEBUG("Create io action %p", action);
void SIMIX_pre_file_stat(smx_simcall_t simcall)
{
smx_action_t action = SIMIX_file_stat(simcall->issuer,
+ simcall->file_stat.storage,
simcall->file_stat.fd,
simcall->file_stat.buf);
xbt_fifo_push(action->simcalls, simcall);
simcall->issuer->waiting_action = action;
}
-smx_action_t SIMIX_file_stat(smx_process_t process, int fd, void* buf)
+smx_action_t SIMIX_file_stat(smx_process_t process ,const char* storage, int fd, void* buf)
{
smx_action_t action;
smx_host_t host = process->smx_host;
#endif
action->io.host = host;
- action->io.surf_io = surf_workstation_model->extension.workstation.stat(host->host, fd, buf);
+ action->io.surf_io = surf_workstation_model->extension.workstation.stat(host->host, storage, fd, buf);
surf_workstation_model->action_data_set(action->io.surf_io, action);
XBT_DEBUG("Create io action %p", action);
void SIMIX_pre_file_close(smx_simcall_t simcall);
void SIMIX_pre_file_stat(smx_simcall_t simcall);
-smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size_t nmemb, smx_file_t stream);
-smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
-smx_action_t SIMIX_file_open(smx_process_t process, const char* path, const char* mode);
-smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fp);
-smx_action_t SIMIX_file_stat(smx_process_t process, int fd, void* buf);
+smx_action_t SIMIX_file_read(smx_process_t process, const char* storage, void* ptr, size_t size, size_t nmemb, smx_file_t stream);
+smx_action_t SIMIX_file_write(smx_process_t process, const char* storage, const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
+smx_action_t SIMIX_file_open(smx_process_t process, const char* storage, const char* path, const char* mode);
+smx_action_t SIMIX_file_close(smx_process_t process, const char* storage, smx_file_t fp);
+smx_action_t SIMIX_file_stat(smx_process_t process, const char* storage, int fd, void* buf);
void SIMIX_post_io(smx_action_t action);
void SIMIX_io_destroy(smx_action_t action);
} sem_get_capacity;
struct {
+ const char* storage;
void *ptr;
size_t size;
size_t nmemb;
} file_read;
struct {
+ const char* storage;
const void *ptr;
size_t size;
size_t nmemb;
} file_write;
struct {
+ const char* storage;
const char* path;
const char* mode;
smx_file_t result;
} file_open;
struct {
+ const char* storage;
smx_file_t fp;
int result;
} file_close;
struct {
+ const char* storage;
int fd;
//Next should be struct stat* buf
void* buf;
return simcall->sem_get_capacity.result;
}
-size_t simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+size_t simcall_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, smx_file_t stream)
{
smx_simcall_t simcall = SIMIX_simcall_mine();
simcall->call = SIMCALL_FILE_READ;
+ simcall->file_read.storage = storage;
simcall->file_read.ptr = ptr;
simcall->file_read.size = size;
simcall->file_read.nmemb = nmemb;
return simcall->file_read.result;
}
-size_t simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+size_t simcall_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, smx_file_t stream)
{
smx_simcall_t simcall = SIMIX_simcall_mine();
simcall->call = SIMCALL_FILE_WRITE;
+ simcall->file_write.storage = storage;
simcall->file_write.ptr = ptr;
simcall->file_write.size = size;
simcall->file_write.nmemb = nmemb;
return simcall->file_write.result;
}
-smx_file_t simcall_file_open(const char* path, const char* mode)
+smx_file_t simcall_file_open(const char* storage, const char* path, const char* mode)
{
smx_simcall_t simcall = SIMIX_simcall_mine();
simcall->call = SIMCALL_FILE_OPEN;
+ simcall->file_open.storage = storage;
simcall->file_open.path = path;
simcall->file_open.mode = mode;
SIMIX_simcall_push(simcall->issuer);
return simcall->file_open.result;
}
-int simcall_file_close(smx_file_t fp)
+int simcall_file_close(const char* storage, smx_file_t fp)
{
smx_simcall_t simcall = SIMIX_simcall_mine();
simcall->call = SIMCALL_FILE_CLOSE;
+ simcall->file_close.storage = storage;
simcall->file_close.fp = fp;
SIMIX_simcall_push(simcall->issuer);
return simcall->file_close.result;
}
-int simcall_file_stat(int fd, void* buf)
+int simcall_file_stat(const char* storage, int fd, void* buf)
{
smx_simcall_t simcall = SIMIX_simcall_mine();
simcall->call = SIMCALL_FILE_STAT;
+ simcall->file_stat.storage = storage;
simcall->file_stat.fd = fd;
simcall->file_stat.buf = buf;
SIMIX_simcall_push(simcall->issuer);
#include "xbt/dict.h"
#include "portable.h"
#include "surf_private.h"
+#include "storage_private.h"
#include "surf/surf_resource.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf,
"Logging specific to the SURF storage module");
surf_model_t surf_storage_model = NULL;
+lmm_system_t storage_maxmin_system = NULL;
+static int storage_selective_update = 0;
+static xbt_swag_t
+ storage_running_action_set_that_does_not_need_being_checked = NULL;
+
+#define GENERIC_LMM_ACTION(action) action->generic_lmm_action
+#define GENERIC_ACTION(action) GENERIC_LMM_ACTION(action).generic_action
typedef struct surf_storage {
s_surf_resource_t generic_resource;
const char* content; /*should be a dict */
} s_surf_storage_t, *surf_storage_t;
+static void storage_action_state_set(surf_action_t action, e_surf_action_state_t state);
+static surf_action_t storage_action_sleep (void *storage, double duration);
+
static surf_action_t storage_action_open(void *storage, const char* path, const char* mode)
{
- return NULL;
+ return storage_action_sleep(storage,1.0);
}
static surf_action_t storage_action_close(void *storage, surf_file_t fp)
{
- return NULL;
+ return storage_action_sleep(storage,2.0);
}
static surf_action_t storage_action_read(void *storage, void* ptr, size_t size, size_t nmemb, surf_file_t stream)
{
- return NULL;
+ return storage_action_sleep(storage,3.0);
}
static surf_action_t storage_action_write(void *storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream)
{
- return NULL;
+ return storage_action_sleep(storage,4.0);
}
static surf_action_t storage_action_stat(void *storage, int fd, void* buf)
{
- return NULL;
+ return storage_action_sleep(storage,5.0);
}
-static void* storage_create_resource(const char* id, const char* type,
+static surf_action_t storage_action_execute (void *storage, double size)
+{
+ surf_action_storage_t action = NULL;
+ storage_t STORAGE = storage;
+
+ XBT_IN("(%s,%g)", surf_resource_name(STORAGE), size);
+ action =
+ surf_action_new(sizeof(s_surf_action_storage_t), size, surf_storage_model,
+ STORAGE->state_current != SURF_RESOURCE_ON);
+
+ GENERIC_LMM_ACTION(action).suspended = 0; /* Should be useless because of the
+ calloc but it seems to help valgrind... */
+ GENERIC_LMM_ACTION(action).variable =
+ lmm_variable_new(storage_maxmin_system, action, 1.0, -1.0 , 1);
+ XBT_OUT();
+ return (surf_action_t) action;
+}
+
+static surf_action_t storage_action_sleep (void *storage, double duration)
+{
+ surf_action_storage_t action = NULL;
+
+ if (duration > 0)
+ duration = MAX(duration, MAXMIN_PRECISION);
+
+ XBT_IN("(%s,%g)", surf_resource_name(storage), duration);
+ action = (surf_action_storage_t) storage_action_execute(storage, 1.0);
+ GENERIC_ACTION(action).max_duration = duration;
+ GENERIC_LMM_ACTION(action).suspended = 2;
+ if (duration == NO_MAX_DURATION) {
+ /* Move to the *end* of the corresponding action set. This convention
+ is used to speed up update_resource_state */
+ xbt_swag_remove(action, ((surf_action_t) action)->state_set);
+ ((surf_action_t) action)->state_set =
+ storage_running_action_set_that_does_not_need_being_checked;
+ xbt_swag_insert(action, ((surf_action_t) action)->state_set);
+ }
+ XBT_OUT();
+ return (surf_action_t) action;
+}
+
+static void* storage_create_resource(const char* id, const char* model,const char* type_id,
const char* content, xbt_dict_t storage_properties)
{
- return NULL;
+ storage_t storage = NULL;
+
+ xbt_assert(!surf_storage_resource_by_name(id),
+ "Storage '%s' declared several times in the platform file",
+ id);
+ storage = (storage_t) surf_resource_new(sizeof(s_storage_t),
+ surf_storage_model, id,storage_properties);
+
+ storage->state_current = SURF_RESOURCE_ON;
+
+ xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, storage);
+
+ XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s' \n\t\tmodel '%s' \n\t\tcontent '%s'\n\t\tproperties '%p'\n",
+ id,
+ model,
+ type_id,
+ content,
+ storage_properties);
+
+ return storage;
}
static void storage_finalize(void)
{
+ lmm_system_free(storage_maxmin_system);
+ storage_maxmin_system = NULL;
+
surf_model_exit(surf_storage_model);
surf_storage_model = NULL;
+
+ xbt_swag_free
+ (storage_running_action_set_that_does_not_need_being_checked);
+ storage_running_action_set_that_does_not_need_being_checked = NULL;
}
static void storage_update_actions_state(double now, double delta)
{
-
+ surf_action_storage_t action = NULL;
+ surf_action_storage_t next_action = NULL;
+ xbt_swag_t running_actions = surf_storage_model->states.running_action_set;
+ xbt_swag_foreach_safe(action, next_action, running_actions) {
+
+ double_update(&(GENERIC_ACTION(action).remains),
+ lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable) * delta);
+ if (GENERIC_LMM_ACTION(action).generic_action.max_duration != NO_MAX_DURATION)
+ double_update(&(GENERIC_ACTION(action).max_duration), delta);
+ if ((GENERIC_ACTION(action).remains <= 0) &&
+ (lmm_get_variable_weight(GENERIC_LMM_ACTION(action).variable) > 0)) {
+ GENERIC_ACTION(action).finish = surf_get_clock();
+ storage_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
+ } else if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION) &&
+ (GENERIC_ACTION(action).max_duration <= 0)) {
+ GENERIC_ACTION(action).finish = surf_get_clock();
+ storage_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
+ }
+ }
+
+ return;
}
static double storage_share_resources(double NOW)
{
- double min_action_duration = -1;
- return min_action_duration;
+ XBT_DEBUG("storage_share_resources %f",NOW);
+ s_surf_action_storage_t action;
+ return generic_maxmin_share_resources(surf_storage_model->states.running_action_set,
+ xbt_swag_offset(action, generic_lmm_action.variable),
+ storage_maxmin_system, lmm_solve);
}
static int storage_resource_used(void *resource_id)
static int storage_action_unref(surf_action_t action)
{
- THROW_UNIMPLEMENTED;
+ action->refcount--;
+ if (!action->refcount) {
+ xbt_swag_remove(action, action->state_set);
+ if (((surf_action_lmm_t) action)->variable)
+ lmm_variable_free(storage_maxmin_system,
+ ((surf_action_lmm_t) action)->variable);
+#ifdef HAVE_TRACING
+ xbt_free(action->category);
+#endif
+ surf_action_free(&action);
+ return 1;
+ }
return 0;
}
static void storage_action_cancel(surf_action_t action)
{
- THROW_UNIMPLEMENTED;
+ surf_action_state_set(action, SURF_ACTION_FAILED);
+ return;
}
static void storage_action_state_set(surf_action_t action, e_surf_action_state_t state)
{
- THROW_UNIMPLEMENTED;
+ surf_action_state_set(action, state);
+ return;
}
static void storage_action_suspend(surf_action_t action)
{
- THROW_UNIMPLEMENTED;
+ XBT_IN("(%p)", action);
+ if (((surf_action_lmm_t) action)->suspended != 2) {
+ lmm_update_variable_weight(storage_maxmin_system,
+ ((surf_action_lmm_t) action)->variable,
+ 0.0);
+ ((surf_action_lmm_t) action)->suspended = 1;
+ }
+ XBT_OUT();
}
static void storage_action_resume(surf_action_t action)
static int storage_action_is_suspended(surf_action_t action)
{
- THROW_UNIMPLEMENTED;
- return 0;
+ return (((surf_action_lmm_t) action)->suspended == 1);
}
static void storage_action_set_max_duration(surf_action_t action, double duration)
static void parse_storage_init(sg_platf_storage_cbarg_t storage)
{
- XBT_DEBUG("parse_storage_init");
+ void* stype = xbt_lib_get_or_null(storage_type_lib,
+ storage->type_id,
+ ROUTING_STORAGE_TYPE_LEVEL);
+ if(!stype) xbt_die("No storage type '%s'",storage->type_id);
+// XBT_INFO("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s' \n\t\tmodel '%s' \n\t\tcontent '%s'\n\t\tproperties '%p'\n",
+// storage->id,
+// ((storage_type_t) stype)->model,
+// ((storage_type_t) stype)->type_id,
+// ((storage_type_t) stype)->content,
+// ((storage_type_t) stype)->properties);
+
+ storage_create_resource(storage->id,
+ ((storage_type_t) stype)->model,
+ ((storage_type_t) stype)->type_id,
+ ((storage_type_t) stype)->content,
+ NULL);
}
static void parse_mstorage_init(sg_platf_mstorage_cbarg_t mstorage)
static void surf_storage_model_init_internal(void)
{
+ s_surf_action_t action;
+
XBT_DEBUG("surf_storage_model_init_internal");
surf_storage_model = surf_model_init();
+ storage_running_action_set_that_does_not_need_being_checked =
+ xbt_swag_new(xbt_swag_offset(action, state_hookup));
+
surf_storage_model->name = "Storage";
surf_storage_model->action_unref = storage_action_unref;
surf_storage_model->action_cancel = storage_action_cancel;
surf_storage_model->extension.storage.write = storage_action_write;
surf_storage_model->extension.storage.stat = storage_action_stat;
surf_storage_model->extension.storage.create_resource = storage_create_resource;
+
+ if (!storage_maxmin_system) {
+ storage_maxmin_system = lmm_system_new(storage_selective_update);
+ }
+
}
void surf_storage_model_init_default(void)
--- /dev/null
+/*
+ * storage_private.h
+ *
+ * Created on: 2 mars 2012
+ * Author: navarro
+ */
+
+#ifndef STORAGE_PRIVATE_H_
+#define STORAGE_PRIVATE_H_
+
+typedef struct storage {
+ s_surf_resource_t generic_resource; /*< Structure with generic data. Needed at begin to interate with SURF */
+ e_surf_resource_state_t state_current; /*< STORAGE current state (ON or OFF) */
+} s_storage_t, *storage_t;
+
+typedef struct surf_action_storage {
+ s_surf_action_lmm_t generic_lmm_action;
+ int index_heap;
+} s_surf_action_storage_t, *surf_action_storage_t;
+
+#endif /* STORAGE_PRIVATE_H_ */
link_lib = xbt_lib_new();
as_router_lib = xbt_lib_new();
storage_lib = xbt_lib_new();
+ storage_type_lib = xbt_lib_new();
XBT_DEBUG("ADD ROUTING LEVEL");
ROUTING_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_free);
ROUTING_ASR_LEVEL = xbt_lib_add_level(as_router_lib,xbt_free);
ROUTING_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,xbt_free);
- ROUTING_STORAGE_TYPE_LEVEL = xbt_lib_add_level(storage_lib,routing_storage_type_free);
ROUTING_STORAGE_HOST_LEVEL = xbt_lib_add_level(storage_lib,routing_storage_host_free);
+ ROUTING_STORAGE_TYPE_LEVEL = xbt_lib_add_level(storage_type_lib,routing_storage_type_free);
XBT_DEBUG("ADD SURF LEVELS");
SURF_CPU_LEVEL = xbt_lib_add_level(host_lib,surf_resource_free);
SURF_WKS_LEVEL = xbt_lib_add_level(host_lib,surf_resource_free);
SURF_LINK_LEVEL = xbt_lib_add_level(link_lib,surf_resource_free);
+ SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_resource_free);
/* Connect our log channels: that must be done manually under windows */
XBT_LOG_CONNECT(surf_cpu, surf);
xbt_lib_free(&link_lib);
xbt_lib_free(&as_router_lib);
xbt_lib_free(&storage_lib);
+ xbt_lib_free(&storage_type_lib);
tmgr_finalize();
surf_parse_lex_destroy();
xbt_lib_t storage_lib;
int ROUTING_STORAGE_LEVEL; //Routing for storagelevel
-int ROUTING_STORAGE_TYPE_LEVEL; //Routing for storage_type level
int ROUTING_STORAGE_HOST_LEVEL;
+int SURF_STORAGE_LEVEL;
+
+xbt_lib_t storage_type_lib;
+int ROUTING_STORAGE_TYPE_LEVEL; //Routing for storage_type level
/* Global vars */
routing_global_t global_routing = NULL;
"Reading a storage, processing unit \"%s\" already exists", storage->id);
// Verification of an existing type_id
- void* storage_type = xbt_lib_get_or_null(storage_lib, storage->type_id,ROUTING_STORAGE_TYPE_LEVEL);
+ void* storage_type = xbt_lib_get_or_null(storage_type_lib, storage->type_id,ROUTING_STORAGE_TYPE_LEVEL);
xbt_assert(storage_type,"Reading a storage, type id \"%s\" does not exists", storage->type_id);
- XBT_INFO("ROUTING Create a storage name '%s' with type_id '%s'",storage->id,storage->type_id);
+ XBT_DEBUG("ROUTING Create a storage name '%s' with type_id '%s'",
+ storage->id,
+ storage->type_id);
- xbt_lib_set(storage_lib,storage->id,ROUTING_STORAGE_LEVEL,(void *) xbt_strdup(storage->type_id));
+ xbt_lib_set(storage_lib,
+ storage->id,
+ ROUTING_STORAGE_LEVEL,
+ (void *) xbt_strdup(storage->type_id));
}
static void routing_parse_storage_type(sg_platf_storage_type_cbarg_t storage_type)
{
- xbt_assert(!xbt_lib_get_or_null(storage_lib, storage_type->id,ROUTING_STORAGE_TYPE_LEVEL),
+ xbt_assert(!xbt_lib_get_or_null(storage_type_lib, storage_type->id,ROUTING_STORAGE_TYPE_LEVEL),
"Reading a storage type, processing unit \"%s\" already exists", storage_type->id);
- XBT_INFO("ROUTING Create a storage type_id '%s' with model '%s'",storage_type->id,storage_type->model);
storage_type_t stype = xbt_new0(s_storage_type_t, 1);
stype->model = xbt_strdup(storage_type->model);
stype->properties = storage_type->properties;
stype->content = xbt_strdup(storage_type->content);
stype->type_id = xbt_strdup(storage_type->id);
- xbt_lib_set(storage_lib,storage_type->id,ROUTING_STORAGE_TYPE_LEVEL,(void *) stype);
+ XBT_DEBUG("ROUTING Create a storage type id '%s' with model '%s' content '%s' and properties '%p'",
+ stype->type_id,
+ stype->model,
+ stype->content,
+ stype->properties);
+
+ xbt_lib_set(storage_type_lib,
+ stype->type_id,
+ ROUTING_STORAGE_TYPE_LEVEL,
+ (void *) stype);
}
static void routing_parse_mstorage(sg_platf_mstorage_cbarg_t mstorage)
{
- mount_t mnt = xbt_new0(s_mount_t, 1);
- mnt->type_id = xbt_strdup(mstorage->type_id);
- mnt->name = xbt_strdup(mstorage->name);
+ THROW_UNIMPLEMENTED;
+// mount_t mnt = xbt_new0(s_mount_t, 1);
+// mnt->id = xbt_strdup(mstorage->type_id);
+// mnt->name = xbt_strdup(mstorage->name);
+//
+// if(!mount_list){
+// XBT_DEBUG("Creata a Mount list for %s",A_surfxml_host_id);
+// mount_list = xbt_dynar_new(sizeof(char *), NULL);
+// }
+// xbt_dynar_push(mount_list,(void *) mnt);
+// free(mnt->id);
+// free(mnt->name);
+// xbt_free(mnt);
+// XBT_DEBUG("ROUTING Mount a storage name '%s' with type_id '%s'",mstorage->name, mstorage->id);
+}
- if(!mount_list){
- XBT_INFO("Creata a Mount list for %s",A_surfxml_host_id);
- mount_list = xbt_dynar_new(sizeof(char *), NULL);
- }
- xbt_dynar_push(mount_list,(void *) mnt);
- free(mnt->type_id);
- free(mnt->name);
- xbt_free(mnt);
- XBT_INFO("ROUTING Mount a storage name '%s' with type_id '%s'",mstorage->name, mstorage->type_id);
+static void mount_free(void *p)
+{
+ mount_t mnt = p;
+ xbt_free(mnt->id);
+ xbt_free(mnt->name);
}
+
static void routing_parse_mount(sg_platf_mount_cbarg_t mount)
{
xbt_assert(storage,"Disk id \"%s\" does not exists", mount->id);
XBT_DEBUG("ROUTING Mount '%s' on '%s'",mount->id, mount->name);
- sg_platf_mstorage_cbarg_t mstorage = xbt_new0(s_sg_platf_mstorage_cbarg_t, 1);
- mstorage->name = xbt_strdup(mount->name);
- mstorage->type_id = xbt_strdup((const char*)storage);
-
- routing_parse_mstorage(mstorage);
- free(mstorage->name);
- free(mstorage->type_id);
- xbt_free(mstorage);
+
+ mount_t mnt = xbt_new0(s_mount_t, 1);
+ mnt->id = xbt_strdup(mount->id);
+ mnt->name = xbt_strdup(mount->name);
+
+ if(!mount_list){
+ XBT_DEBUG("Create a Mount list for %s",A_surfxml_host_id);
+ mount_list = xbt_dynar_new(sizeof(s_mount_t), mount_free);
+ }
+ xbt_dynar_push(mount_list,&mnt);
+
}
static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster)
#include "xbt/dict.h"
#include "portable.h"
#include "surf_private.h"
+#include "storage_private.h"
#include "surf/surf_resource.h"
typedef struct workstation_CLM03 {
workstation->generic_resource.model = surf_workstation_model;
workstation->generic_resource.name = xbt_strdup(host->id);
workstation->cpu = xbt_lib_get_or_null(host_lib, host->id, SURF_CPU_LEVEL);
- workstation->storage = NULL;
-
+ workstation->storage = xbt_lib_get_or_null(storage_lib,host->id,ROUTING_STORAGE_HOST_LEVEL);
+ XBT_DEBUG("Create workstation %s with %ld mounted disks",host->id,xbt_dynar_length(workstation->storage));
xbt_lib_set(host_lib, host->id, SURF_WKS_LEVEL, workstation);
}
return surf_resource_properties(((workstation_CLM03_t) ws)->cpu);
}
-static surf_action_t ws_action_open(void *workstation, const char* path, const char* mode)
-{
- void *storage = ((workstation_CLM03_t) workstation)->storage;
- return ((surf_resource_t) storage)->model->extension.storage.open(storage, path, mode);
-}
-
-static surf_action_t ws_action_close(void *workstation, surf_file_t fp)
-{
- void *storage = ((workstation_CLM03_t) workstation)->storage;
- return ((surf_resource_t) storage)->model->extension.storage.close(storage, fp);
-}
-
-static surf_action_t ws_action_read(void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream)
-{
- void *storage = ((workstation_CLM03_t) workstation)->storage;
- return ((surf_resource_t) storage)->model->extension.storage.read(storage, ptr, size, nmemb, stream);
-}
-
-static surf_action_t ws_action_write(void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream)
-{
- void *storage = ((workstation_CLM03_t) workstation)->storage;
- return ((surf_resource_t) storage)->model->extension.storage.write(storage, ptr, size, nmemb, stream);
-}
-
-static surf_action_t ws_action_stat(void *workstation, int fd, void* buf)
-{
- void *storage = ((workstation_CLM03_t) workstation)->storage;
- return ((surf_resource_t) storage)->model->extension.storage.stat(storage, fd, buf);
+static surf_action_t ws_action_open(void *workstation, const char* storage, const char* path, const char* mode)
+{
+ storage_t st = NULL;
+ mount_t mnt = NULL;
+ unsigned int cursor;
+ xbt_dynar_t storage_list = ((workstation_CLM03_t) workstation)->storage;
+
+ XBT_DEBUG("Search for storage name '%s' on '%s'",storage,((workstation_CLM03_t) workstation)->generic_resource.name);
+ xbt_dynar_foreach(storage_list,cursor,mnt)
+ {
+ XBT_DEBUG("See '%s'",mnt->name);
+ if(!strcmp(storage,mnt->name)){
+ st = surf_storage_resource_by_name(mnt->id);
+ break;
+ }
+ }
+ if(!st) xbt_die("Don't find mount '%s' for '%s'",storage,((workstation_CLM03_t) workstation)->generic_resource.name);
+ XBT_DEBUG("OPEN on disk '%s'",st->generic_resource.name);
+ surf_model_t model = st->generic_resource.model;
+ return model->extension.storage.open(st, path, mode);
+}
+
+static surf_action_t ws_action_close(void *workstation, const char* storage, surf_file_t fp)
+{
+ storage_t st = NULL;
+ mount_t mnt = NULL;
+ unsigned int cursor;
+ xbt_dynar_t storage_list = ((workstation_CLM03_t) workstation)->storage;
+
+ XBT_DEBUG("Search for storage name '%s' on '%s'",storage,((workstation_CLM03_t) workstation)->generic_resource.name);
+ xbt_dynar_foreach(storage_list,cursor,mnt)
+ {
+ XBT_DEBUG("See '%s'",mnt->name);
+ if(!strcmp(storage,mnt->name)){
+ st = surf_storage_resource_by_name(mnt->id);
+ break;
+ }
+ }
+ if(!st) xbt_die("Don't find mount '%s' for '%s'",storage,((workstation_CLM03_t) workstation)->generic_resource.name);
+ XBT_DEBUG("CLOSE on disk '%s'",st->generic_resource.name);
+ surf_model_t model = st->generic_resource.model;
+ return model->extension.storage.close(st, fp);
+}
+
+static surf_action_t ws_action_read(void *workstation, const char* storage, void* ptr, size_t size, size_t nmemb, surf_file_t stream)
+{
+ storage_t st = NULL;
+ mount_t mnt = NULL;
+ unsigned int cursor;
+ xbt_dynar_t storage_list = ((workstation_CLM03_t) workstation)->storage;
+
+ XBT_DEBUG("Search for storage name '%s' on '%s'",storage,((workstation_CLM03_t) workstation)->generic_resource.name);
+ xbt_dynar_foreach(storage_list,cursor,mnt)
+ {
+ XBT_DEBUG("See '%s'",mnt->name);
+ if(!strcmp(storage,mnt->name)){
+ st = surf_storage_resource_by_name(mnt->id);
+ break;
+ }
+ }
+ if(!st) xbt_die("Don't find mount '%s' for '%s'",storage,((workstation_CLM03_t) workstation)->generic_resource.name);
+ XBT_DEBUG("READ on disk '%s'",st->generic_resource.name);
+ surf_model_t model = st->generic_resource.model;
+ return model->extension.storage.read(st, ptr, size, nmemb, stream);
+}
+
+static surf_action_t ws_action_write(void *workstation, const char* storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream)
+{
+ storage_t st = NULL;
+ mount_t mnt = NULL;
+ unsigned int cursor;
+ xbt_dynar_t storage_list = ((workstation_CLM03_t) workstation)->storage;
+
+ XBT_DEBUG("Search for storage name '%s' on '%s'",storage,((workstation_CLM03_t) workstation)->generic_resource.name);
+ xbt_dynar_foreach(storage_list,cursor,mnt)
+ {
+ XBT_DEBUG("See '%s'",mnt->name);
+ if(!strcmp(storage,mnt->name)){
+ st = surf_storage_resource_by_name(mnt->id);
+ break;
+ }
+ }
+ if(!st) xbt_die("Don't find mount '%s' for '%s'",storage,((workstation_CLM03_t) workstation)->generic_resource.name);
+ XBT_DEBUG("WRITE on disk '%s'",st->generic_resource.name);
+ surf_model_t model = st->generic_resource.model;
+ return model->extension.storage.write(st, ptr, size, nmemb, stream);
+}
+
+static surf_action_t ws_action_stat(void *workstation, const char* storage, int fd, void* buf)
+{
+ storage_t st = NULL;
+ mount_t mnt = NULL;
+ unsigned int cursor;
+ xbt_dynar_t storage_list = ((workstation_CLM03_t) workstation)->storage;
+
+ XBT_DEBUG("Search for storage name '%s' on '%s'",storage,((workstation_CLM03_t) workstation)->generic_resource.name);
+ xbt_dynar_foreach(storage_list,cursor,mnt)
+ {
+ XBT_DEBUG("See '%s'",mnt->name);
+ if(!strcmp(storage,mnt->name)){
+ st = surf_storage_resource_by_name(mnt->id);
+ break;
+ }
+ }
+ if(!st) xbt_die("Don't find mount '%s' for '%s'",storage,((workstation_CLM03_t) workstation)->generic_resource.name);
+ XBT_DEBUG("STAT on disk '%s'",st->generic_resource.name);
+ surf_model_t model = st->generic_resource.model;
+ return model->extension.storage.stat(st, fd, buf);
}
static void surf_workstation_model_init_internal(void)