int host(int argc, char *argv[])
{
- m_file_t file;
+ msg_file_t file;
char* mount = bprintf("C:");
size_t read,write;
if(!strcmp(MSG_process_get_name(MSG_process_self()),"0"))
@{ */
typedef struct m_task *m_task_t;
+/* ******************************** File ************************************ */
+
+typedef struct simdata_file *simdata_file_t;
+
+/** @brief File datatype
+ @ingroup m_datatypes_management_details */
+typedef struct msg_file {
+ char *name; /**< @brief file name */
+ simdata_file_t simdata; /**< @brief simulator data */
+ void *data; /**< @brief user data */
+} s_msg_file_t;
+/** @brief File datatype
+ @ingroup m_datatypes_management_details */
+typedef struct msg_file *msg_file_t;
+
/*************** Begin GPU ***************/
typedef struct simdata_gpu_task *simdata_gpu_task_t;
/************************** File handling ***********************************/
-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(size_t) MSG_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, msg_file_t stream);
+XBT_PUBLIC(size_t) MSG_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, msg_file_t stream);
+XBT_PUBLIC(msg_file_t) MSG_file_open(const char* storage, const char* path, const char* mode);
+XBT_PUBLIC(int) MSG_file_close(const char* storage, msg_file_t fp);
XBT_PUBLIC(int) MSG_file_stat(const char* storage, int fd, void* buf);
typedef struct s_smx_timer* smx_timer_t;
+/* ******************************** File ************************************ */
+typedef struct s_smx_file *smx_file_t;
/* ******************************** Synchro ************************************ */
typedef struct s_smx_mutex *smx_mutex_t;
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(const char* storage, void* ptr, size_t size, size_t nmemb, m_file_t stream);
-XBT_PUBLIC(size_t) simcall_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, m_file_t stream);
-XBT_PUBLIC(m_file_t) simcall_file_open(const char* storage, const char* path, const char* mode);
-XBT_PUBLIC(int) simcall_file_close(const char* storage, m_file_t fp);
+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()
#define XBT_BACKTRACE_SIZE 10 /* FIXME: better place? Do document */
-/** @brief File datatype
- @ingroup m_datatypes_management_details */
-typedef struct m_file {
- char *name; /**< @brief file name */
- void *content; /**< @brief user data */
-} s_m_file_t;
-/** @brief File datatype
- @ingroup m_datatypes_management_details */
-typedef struct m_file *m_file_t;
-
-
SG_END_DECL()
#endif /* XBT_MISC_H */
#ifdef HAVE_TRACING
char *category; /**< tracing category for categorized resource utilization monitoring */
#endif
- void* file; /**< m_file_t for storage model */
+ void* file; /**< surf_file_t for storage model */
size_t read_write;
} s_surf_action_t;
* Public functions specific to the Storage model.
*/
+typedef struct surf_file {
+ char *name; /**< @brief host name if any */
+ void *simdata;
+ void *data; /**< @brief user data */
+}s_surf_file_t, *surf_file_t;
+
typedef struct surf_storage_model_extension_public {
surf_action_t(*open) (void *storage, const char* path, const char* mode);
- surf_action_t(*close) (void *storage, m_file_t fp);
- surf_action_t(*read) (void *storage, void* ptr, size_t size, size_t nmemb, m_file_t stream);
- surf_action_t(*write) (void *storage, const void* ptr, size_t size, size_t nmemb, m_file_t stream);
+ 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);
} s_surf_model_extension_storage_t;
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* storage, const char* path, const char* mode);
- surf_action_t(*close) (void *workstation, const char* storage, m_file_t fp);
- surf_action_t(*read) (void *workstation, const char* storage, void* ptr, size_t size, size_t nmemb, m_file_t stream);
- surf_action_t(*write) (void *workstation, const char* storage, const void* ptr, size_t size, size_t nmemb, m_file_t stream);
+ 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);
/** @addtogroup m_file_management
* \htmlonly <!-- DOXYGEN_NAVBAR_LABEL="File" --> \endhtmlonly
- * (#m_file_t) and the functions for managing it.
+ * (#msg_file_t) and the functions for managing it.
*
- * \see #m_file_t
+ * \see #msg_file_t
*/
/********************************* File **************************************/
* \param stream to read
* \return the number of items successfully read
*/
-size_t MSG_file_read(const char* storage, 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, msg_file_t stream)
{
- return simcall_file_read(storage, ptr, size, nmemb, (m_file_t)stream);
+ return simcall_file_read(storage, ptr, size, nmemb, (smx_file_t)stream);
}
/** \ingroup m_file_management
* \param stream to write
* \return the number of items successfully write
*/
-size_t MSG_file_write(const char* storage, 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, msg_file_t stream)
{
- return simcall_file_write(storage, ptr, size, nmemb, (m_file_t)stream);
+ return simcall_file_write(storage, ptr, size, nmemb, (smx_file_t)stream);
}
/** \ingroup m_file_management
* a+ Open for reading and appending (writing at end of file). The file is created if it does not exist. The initial file position for reading
* is at the beginning of the file, but output is always appended to the end of the file.
*
- * \return An #m_file_t associated to the file
+ * \return An #msg_file_t associated to the file
*/
-m_file_t MSG_file_open(const char* storage, const char* path, const char* mode)
+msg_file_t MSG_file_open(const char* storage, const char* path, const char* mode)
{
- return (m_file_t) simcall_file_open(storage, path, mode);
+ return (msg_file_t) simcall_file_open(storage, path, mode);
}
/** \ingroup m_file_management
* \param fp is the file to close
* \return 0 on success or 1 on error
*/
-int MSG_file_close(const char* storage, m_file_t fp)
+int MSG_file_close(const char* storage, msg_file_t fp)
{
- return simcall_file_close(storage, (m_file_t)fp);
+ return simcall_file_close(storage, (smx_file_t)fp);
}
/** \ingroup m_file_management
simcall->file_read.result = (action->io.surf_io)->read_write;
}
-smx_action_t SIMIX_file_read(smx_process_t process, const char* storage, void* ptr, size_t size, size_t nmemb, m_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, storage, ptr, size, nmemb, 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);
simcall->file_write.result = (action->io.surf_io)->read_write;
}
-smx_action_t SIMIX_file_write(smx_process_t process, const char* storage, const void* ptr, size_t size, size_t nmemb, m_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, storage, ptr, size, nmemb, 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);
simcall->file_close.result = 0;
}
-smx_action_t SIMIX_file_close(smx_process_t process ,const char* storage, m_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, storage, 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);
#include "simix/datatypes.h"
#include "smx_smurf_private.h"
+/** @brief File datatype */
+typedef struct s_smx_file {
+ char *name; /**< @brief host name if any */
+ void *simdata;
+ void *data; /**< @brief user data */
+} s_smx_file_t;
+
void SIMIX_pre_file_read(smx_simcall_t simcall);
void SIMIX_pre_file_write(smx_simcall_t simcall);
void SIMIX_pre_file_open(smx_simcall_t simcall);
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, const char* storage, void* ptr, size_t size, size_t nmemb, m_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, m_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 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, m_file_t fp);
+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 *ptr;
size_t size;
size_t nmemb;
- m_file_t stream;
+ smx_file_t stream;
size_t result;
} file_read;
const void *ptr;
size_t size;
size_t nmemb;
- m_file_t stream;
+ smx_file_t stream;
size_t result;
} file_write;
const char* storage;
const char* path;
const char* mode;
- m_file_t result;
+ smx_file_t result;
} file_open;
struct {
const char* storage;
- m_file_t fp;
+ smx_file_t fp;
int result;
} file_close;
return simcall->sem_get_capacity.result;
}
-size_t simcall_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, m_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();
return simcall->file_read.result;
}
-size_t simcall_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, m_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();
return simcall->file_write.result;
}
-m_file_t simcall_file_open(const char* storage, 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();
return simcall->file_open.result;
}
-int simcall_file_close(const char* storage, m_file_t fp)
+int simcall_file_close(const char* storage, smx_file_t fp)
{
smx_simcall_t simcall = SIMIX_simcall_mine();
xbt_dict_t content_dict = storage_type->content;
content_t content = xbt_dict_get(content_dict,path);
- m_file_t file = xbt_new0(s_m_file_t,1);
+ surf_file_t file = xbt_new0(s_surf_file_t,1);
file->name = xbt_strdup(path);
- file->content = content;
+ file->simdata = content;
surf_action_t action = storage_action_execute(storage,0, DEFAULT);
action->file = (void *)file;
return action;
}
-static surf_action_t storage_action_close(void *storage, m_file_t fp)
+static surf_action_t storage_action_close(void *storage, surf_file_t fp)
{
char *filename = fp->name;
free(fp->name);
- fp->content = NULL;
+ fp->simdata = NULL;
xbt_free(fp);
surf_action_t action = storage_action_execute(storage,0, DEFAULT);
XBT_DEBUG("\tClose file '%s'",filename);
return action;
}
-static surf_action_t storage_action_read(void *storage, void* ptr, size_t size, size_t nmemb, m_file_t stream)
+static surf_action_t storage_action_read(void *storage, void* ptr, size_t size, size_t nmemb, surf_file_t stream)
{
char *filename = stream->name;
- content_t content = (content_t)(stream->content);
+ content_t content = (content_t)(stream->simdata);
XBT_DEBUG("\tRead file '%s' size '%Zu/%Zu'",filename,size,content->size);
if(size > content->size)
size = content->size;
return action;
}
-static surf_action_t storage_action_write(void *storage, const void* ptr, size_t size, size_t nmemb, m_file_t stream)
+static surf_action_t storage_action_write(void *storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream)
{
char *filename = stream->name;
- content_t content = (content_t)(stream->content);
+ content_t content = (content_t)(stream->simdata);
XBT_DEBUG("\tWrite file '%s' size '%Zu/%Zu'",filename,size,content->size);
surf_action_t action = storage_action_execute(storage,size,WRITE);
return model->extension.storage.open(st, path, mode);
}
-static surf_action_t ws_action_close(void *workstation, const char* storage, m_file_t fp)
+static surf_action_t ws_action_close(void *workstation, const char* storage, surf_file_t fp)
{
storage_t st = find_storage_on_mount_list(workstation, storage);
XBT_DEBUG("CLOSE on disk '%s'",st->generic_resource.name);
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, m_file_t stream)
+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 = find_storage_on_mount_list(workstation, storage);
XBT_DEBUG("READ on disk '%s'",st->generic_resource.name);
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, m_file_t 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 = find_storage_on_mount_list(workstation, storage);
XBT_DEBUG("WRITE on disk '%s'",st->generic_resource.name);