} MSG_error_t;
/** @} */
+/* ******************************** File ************************************ */
+
+/** @brief File datatype
+ @ingroup m_datatypes_management_details */
+typedef struct m_file {
+ char *name; /**< @brief host name if any */
+ void *data; /**< @brief user data */
+} s_m_file_t;
+/** @} */
+
SG_END_DECL()
#endif
SG_BEGIN_DECL()
+/* ****************************** File *********************************** */
+typedef struct s_smx_file *smx_file_t;
+
+
+
/* ******************************** Host ************************************ */
/** @defgroup m_datatypes_management_details Details on SIMIX datatypes */
/** @brief Host datatype
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(void) simcall_file_read(char* name);
+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);
SG_END_DECL()
#endif /* _SIMIX_SIMIX_H */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix,
"Logging specific to SIMIX (io)");
+
+//SIMIX FILE READ
void SIMIX_pre_file_read(smx_simcall_t simcall)
{
- smx_action_t action = SIMIX_file_read(simcall->issuer, simcall->file_read.name);
+ smx_action_t action = SIMIX_file_read(simcall->issuer,
+ simcall->file_read.ptr,
+ simcall->file_read.size,
+ simcall->file_read.nmemb,
+ simcall->file_read.stream);
xbt_fifo_push(action->simcalls, simcall);
simcall->issuer->waiting_action = action;
}
-smx_action_t SIMIX_file_read(smx_process_t process, char* name)
+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 action;
smx_host_t host = process->smx_host;
return action;
}
+//SIMIX FILE WRITE
+void SIMIX_pre_file_write(smx_simcall_t simcall)
+{
+ smx_action_t action = SIMIX_file_write(simcall->issuer,
+ simcall->file_write.ptr,
+ simcall->file_write.size,
+ simcall->file_write.nmemb,
+ simcall->file_write.stream);
+ xbt_fifo_push(action->simcalls, simcall);
+ 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 action;
+ smx_host_t host = process->smx_host;
+
+ /* check if the host is active */
+ if (surf_workstation_model->extension.
+ workstation.get_state(host->host) != SURF_RESOURCE_ON) {
+ THROWF(host_error, 0, "Host %s failed, you cannot call this function",
+ host->name);
+ }
+
+ action = xbt_mallocator_get(simix_global->action_mallocator);
+ action->type = SIMIX_ACTION_IO;
+ action->name = NULL;
+#ifdef HAVE_TRACING
+ action->category = NULL;
+#endif
+
+ action->io.host = host;
+ // TODO in surf model disk???
+ // action->io.surf_io = surf_workstation_model->extension.disk.write(host->host, name),
+ action->io.surf_io = surf_workstation_model->extension.workstation.sleep(host->host, 2.0);
+
+ surf_workstation_model->action_data_set(action->io.surf_io, action);
+ XBT_DEBUG("Create io action %p", action);
+
+ return action;
+}
+
void SIMIX_post_io(smx_action_t action)
{
switch (surf_workstation_model->action_state_get(action->io.surf_io)) {
#include "simix/datatypes.h"
#include "smx_smurf_private.h"
+/** @brief File datatype
+ @ingroup m_datatypes_management_details */
+typedef struct s_smx_file {
+ char *name; /**< @brief host name if any */
+ void *data; /**< @brief user data */
+} s_smx_file_t;
+typedef struct s_smx_file *smx_file_t;
+/** @} */
+
void SIMIX_pre_file_read(smx_simcall_t simcall);
-smx_action_t SIMIX_file_read(smx_process_t process, char* name);
+void SIMIX_pre_file_write(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);
+
void SIMIX_post_io(smx_action_t action);
void SIMIX_io_destroy(smx_action_t action);
void SIMIX_io_finish(smx_action_t action);
SIMIX_pre_file_read(simcall);
break;
+ case SIMCALL_FILE_WRITE:
+ SIMIX_pre_file_write(simcall);
+ break;
+
case SIMCALL_NONE:
THROWF(arg_error,0,"Asked to do the noop syscall on %s@%s",
SIMIX_process_get_name(simcall->issuer),
SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_ACQUIRE),\
SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_ACQUIRE_TIMEOUT),\
SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_GET_CAPACITY),\
-SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_READ)
+SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_READ),\
+SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_WRITE),\
+SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_OPEN),\
+SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_CLOSE),\
+SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_STAT)
+
/* SIMCALL_COMM_IS_LATENCY_BOUNDED and SIMCALL_SET_CATEGORY make things complicated
* because they are not always present */
} sem_get_capacity;
struct {
- char* name;;
+ void *ptr;
+ size_t size;
+ size_t nmemb;
+ smx_file_t* stream;
+ size_t result;
} file_read;
+
+ struct {
+ const void *ptr;
+ size_t size;
+ size_t nmemb;
+ smx_file_t* stream;
+ size_t result;
+ } file_write;
};
} s_smx_simcall_t, *smx_simcall_t;
return simcall->sem_get_capacity.result;
}
-void simcall_file_read(char* name)
+size_t simcall_file_read(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.name = name;
+ simcall->file_read.ptr = ptr;
+ simcall->file_read.size = size;
+ simcall->file_read.nmemb = nmemb;
+ simcall->file_read.stream = stream;
SIMIX_simcall_push(simcall->issuer);
+
+ return simcall->file_read.result;
+}
+
+size_t simcall_file_write(const 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_write.ptr = ptr;
+ simcall->file_write.size = size;
+ simcall->file_write.nmemb = nmemb;
+ simcall->file_write.stream = stream;
+ SIMIX_simcall_push(simcall->issuer);
+
+ return simcall->file_write.result;
}
/* ************************************************************************** */