#include "xbt/misc.h"
#include "xbt/fifo.h"
#include "xbt/dict.h"
-#include "xbt/file_stat.h"
#include "xbt/function_types.h"
#include "xbt/parmap.h"
#include "xbt/swag.h"
+#include "simgrid/platf.h" // ws_params_t
+
SG_BEGIN_DECL()
+/**************************** Scalar Values **********************************/
+
+typedef union u_smx_scalar u_smx_scalar_t;
/* ******************************** Host ************************************ */
-/** @defgroup m_datatypes_management_details Details on SIMIX datatypes */
/** @brief Host datatype
- @ingroup m_datatypes_management
+ @ingroup simix_host_management
A <em>location</em> (or <em>host</em>) is any possible place where
a process may run. Thus it is represented as a <em>physical
\see m_host_management
@{ */
-typedef struct s_smx_host *smx_host_t;
+typedef xbt_dictelm_t smx_host_t;
+typedef struct s_smx_host_priv *smx_host_priv_t;
typedef enum {
SIMIX_WAITING,
SIMIX_READY,
typedef struct s_smx_timer* smx_timer_t;
/* ******************************** Synchro ************************************ */
+/**
+ * \ingroup simix_synchro_management
+ */
typedef struct s_smx_mutex *smx_mutex_t;
+/**
+ * \ingroup simix_synchro_management
+ */
typedef struct s_smx_cond *smx_cond_t;
+/**
+ * \ingroup simix_synchro_management
+ */
typedef struct s_smx_sem *smx_sem_t;
/********************************** File *************************************/
typedef struct s_smx_file *smx_file_t;
-typedef struct s_smx_stat *smx_stat_t;
/********************************** Action *************************************/
typedef struct s_smx_action *smx_action_t; /* FIXME: replace by specialized action handlers */
/* ****************************** Process *********************************** */
/** @brief Process datatype
- @ingroup m_datatypes_management
+ @ingroup simix_process_management
A processt may be defined as a <em>code</em>, with some <em>private
data</em>, executing in a <em>location</em>.
/* kill_time */ double,
/* argc */ int,
/* argv */ char**,
- /* props */ xbt_dict_t);
+ /* props */ xbt_dict_t,
+ /* auto_restart */ int);
/******************************* Networking ***********************************/
+/**
+ * \ingroup simix_rdv_management
+ */
typedef struct s_smx_rvpoint *smx_rdv_t;
+XBT_PUBLIC(void*) SIMIX_comm_get_src_data(smx_action_t action);
+XBT_PUBLIC(void*) SIMIX_comm_get_dst_data(smx_action_t action);
+
/******************************** Context *************************************/
typedef struct s_smx_context *smx_context_t;
typedef struct s_smx_context_factory *smx_context_factory_t;
/* Process creation/destruction callbacks */
typedef void (*void_pfn_smxprocess_t) (smx_process_t);
-
+/* Process kill */
+typedef void (*void_pfn_smxprocess_t_smxprocess_t) (smx_process_t, smx_process_t);
+/* for auto-restart function */
+typedef void (*void_pfn_smxhost_t) (smx_host_t);
/* The following function pointer types describe the interface that any context
factory should implement */
XBT_PUBLIC(smx_ctx_factory_initializer_t) smx_factory_initializer_to_use;
extern char* smx_context_factory_name;
extern int smx_context_stack_size;
-
-#ifdef HAVE_THREAD_LOCAL_STORAGE
-extern __thread smx_context_t smx_current_context;
-#else
-extern smx_context_t smx_current_context;
-#endif
+extern int smx_context_stack_size_was_set;
/* *********************** */
/* Context type definition */
void *data; /* Here SIMIX stores the smx_process_t containing the context */
char **argv;
int argc;
- int iwannadie:1;
+ unsigned iwannadie:1;
} s_smx_ctx_base_t;
/* methods of this class */
/********************************** Global ************************************/
/* Initialization and exit */
XBT_PUBLIC(void) SIMIX_global_init(int *argc, char **argv);
-XBT_PUBLIC(void) SIMIX_clean(void);
XBT_PUBLIC(void) SIMIX_function_register_process_cleanup(void_pfn_smxprocess_t function);
XBT_PUBLIC(void) SIMIX_function_register_process_create(smx_creation_func_t function);
-XBT_PUBLIC(void) SIMIX_function_register_process_kill(void_pfn_smxprocess_t function);
+XBT_PUBLIC(void) SIMIX_function_register_process_kill(void_pfn_smxprocess_t_smxprocess_t function);
/* Simulation execution */
XBT_PUBLIC(void) SIMIX_run(void);
XBT_PUBLIC(void) SIMIX_function_register(const char *name, xbt_main_func_t code);
XBT_PUBLIC(void) SIMIX_function_register_default(xbt_main_func_t code);
XBT_PUBLIC(xbt_main_func_t) SIMIX_get_registered_function(const char *name);
+XBT_PUBLIC(void) SIMIX_init_application(void);
XBT_PUBLIC(void) SIMIX_launch_application(const char *file);
+
XBT_PUBLIC(void) SIMIX_process_set_function(const char* process_host,
const char *process_function,
xbt_dynar_t arguments,
double process_kill_time);
/*********************************** Host *************************************/
-XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_dict(void);
+//XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_dict(u_smx_scalar_t *args);
XBT_PUBLIC(smx_host_t) SIMIX_host_get_by_name(const char *name);
XBT_PUBLIC(smx_host_t) SIMIX_host_self(void);
XBT_PUBLIC(const char*) SIMIX_host_self_get_name(void);
XBT_PUBLIC(const char*) SIMIX_host_get_name(smx_host_t host); /* FIXME: make private: only the name of SIMIX_host_self() should be public without request */
+XBT_PUBLIC(void) SIMIX_host_on(smx_host_t host);
+XBT_PUBLIC(void) SIMIX_host_off(smx_host_t host, smx_process_t issuer);
XBT_PUBLIC(void) SIMIX_host_self_set_data(void *data);
XBT_PUBLIC(void*) SIMIX_host_self_get_data(void);
+XBT_PUBLIC(void*) SIMIX_host_get_data(smx_host_t host);
+XBT_PUBLIC(void) SIMIX_host_set_data(smx_host_t host, void *data);
/********************************* Process ************************************/
XBT_PUBLIC(int) SIMIX_process_count(void);
XBT_PUBLIC(smx_context_t) SIMIX_process_get_context(smx_process_t);
XBT_PUBLIC(void) SIMIX_process_set_context(smx_process_t p,smx_context_t c);
XBT_PUBLIC(int) SIMIX_process_has_pending_comms(smx_process_t process);
+XBT_PUBLIC(void) SIMIX_process_on_exit_runall(smx_process_t process);
+XBT_PUBLIC(void) SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data);
/****************************** Communication *********************************/
XBT_PUBLIC(void) SIMIX_comm_set_copy_data_callback(void (*callback) (smx_action_t, void*, size_t));
XBT_PUBLIC(void) SIMIX_comm_copy_pointer_callback(smx_action_t comm, void* buff, size_t buff_size);
XBT_PUBLIC(void) SIMIX_comm_copy_buffer_callback(smx_action_t comm, void* buff, size_t buff_size);
-XBT_PUBLIC(void) smpi_comm_copy_data_callback(smx_action_t comm, void* buff, size_t buff_size);
XBT_PUBLIC(smx_action_t) SIMIX_comm_get_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
XBT_PUBLIC(int) SIMIX_comm_has_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
/******************************* Host simcalls ********************************/
/* TODO use handlers and keep smx_host_t hidden from higher levels */
-XBT_PUBLIC(xbt_dict_t) simcall_host_get_dict(void);
XBT_PUBLIC(smx_host_t) simcall_host_get_by_name(const char *name);
XBT_PUBLIC(const char *) simcall_host_get_name(smx_host_t host);
XBT_PUBLIC(xbt_dict_t) simcall_host_get_properties(smx_host_t host);
+XBT_PUBLIC(void) simcall_host_on(smx_host_t host);
+XBT_PUBLIC(void) simcall_host_off(smx_host_t host);
+XBT_PUBLIC(int) simcall_host_get_core(smx_host_t host);
XBT_PUBLIC(double) simcall_host_get_speed(smx_host_t host);
XBT_PUBLIC(double) simcall_host_get_available_speed(smx_host_t host);
/* Two possible states, 1 - CPU ON and 0 CPU OFF */
XBT_PUBLIC(smx_action_t) simcall_host_execute(const char *name, smx_host_t host,
double computation_amount,
- double priority);
+ double priority, double bound, unsigned long affinity_mask);
XBT_PUBLIC(smx_action_t) simcall_host_parallel_execute(const char *name,
int host_nb,
smx_host_t *host_list,
XBT_PUBLIC(double) simcall_host_execution_get_remains(smx_action_t execution);
XBT_PUBLIC(e_smx_state_t) simcall_host_execution_get_state(smx_action_t execution);
XBT_PUBLIC(void) simcall_host_execution_set_priority(smx_action_t execution, double priority);
+XBT_PUBLIC(void) simcall_host_execution_set_bound(smx_action_t execution, double bound);
+XBT_PUBLIC(void) simcall_host_execution_set_affinity(smx_action_t execution, smx_host_t host, unsigned long mask);
XBT_PUBLIC(e_smx_state_t) simcall_host_execution_wait(smx_action_t execution);
-
+XBT_PUBLIC(void) simcall_host_get_params(smx_host_t vm, ws_params_t param);
+XBT_PUBLIC(void) simcall_host_set_params(smx_host_t vm, ws_params_t param);
+
+/******************************* VM simcalls ********************************/
+// Create the vm_workstation at the SURF level
+XBT_PUBLIC(void*) simcall_vm_create(const char *name, smx_host_t host);
+XBT_PUBLIC(int) simcall_vm_get_state(smx_host_t vm);
+XBT_PUBLIC(void) simcall_vm_start(smx_host_t vm);
+XBT_PUBLIC(void) simcall_vm_migrate(smx_host_t vm, smx_host_t dst_pm);
+XBT_PUBLIC(void *) simcall_vm_get_pm(smx_host_t vm);
+XBT_PUBLIC(void) simcall_vm_set_bound(smx_host_t vm, double bound);
+XBT_PUBLIC(void) simcall_vm_set_affinity(smx_host_t vm, smx_host_t pm, unsigned long mask);
+XBT_PUBLIC(void) simcall_vm_resume(smx_host_t vm);
+XBT_PUBLIC(void) simcall_vm_save(smx_host_t vm);
+XBT_PUBLIC(void) simcall_vm_restore(smx_host_t vm);
+XBT_PUBLIC(void) simcall_vm_suspend(smx_host_t vm);
+XBT_PUBLIC(void) simcall_vm_destroy(smx_host_t vm);
+XBT_PUBLIC(void) simcall_vm_shutdown(smx_host_t vm);
/**************************** Process simcalls ********************************/
/* Constructor and Destructor */
const char *hostname,
double kill_time,
int argc, char **argv,
- xbt_dict_t properties);
+ xbt_dict_t properties,
+ int auto_restart);
XBT_PUBLIC(void) simcall_process_kill(smx_process_t process);
-XBT_PUBLIC(void) simcall_process_killall(void);
+XBT_PUBLIC(void) simcall_process_killall(int reset_pid);
/* Process handling */
XBT_PUBLIC(void) simcall_process_cleanup(smx_process_t process);
XBT_PUBLIC(void) simcall_process_change_host(smx_process_t process,
- smx_host_t dest);
+ smx_host_t dest);
XBT_PUBLIC(void) simcall_process_suspend(smx_process_t process);
XBT_PUBLIC(void) simcall_process_resume(smx_process_t process);
XBT_PUBLIC(void) simcall_process_set_data(smx_process_t process, void *data);
XBT_PUBLIC(smx_host_t) simcall_process_get_host(smx_process_t process);
XBT_PUBLIC(const char *) simcall_process_get_name(smx_process_t process);
+XBT_PUBLIC(int) simcall_process_get_PID(smx_process_t process);
+XBT_PUBLIC(int) simcall_process_get_PPID(smx_process_t process);
XBT_PUBLIC(int) simcall_process_is_suspended(smx_process_t process);
XBT_PUBLIC(xbt_dict_t) simcall_process_get_properties(smx_process_t host);
-
+XBT_PUBLIC(void) simcall_process_set_kill_time(smx_process_t process, double kill_time);
+XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data);
+XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart);
+XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process);
/* Sleep control */
XBT_PUBLIC(e_smx_state_t) simcall_process_sleep(double duration);
XBT_PUBLIC(smx_rdv_t) simcall_rdv_get_by_name(const char *name);
XBT_PUBLIC(int) simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host);
XBT_PUBLIC(smx_action_t) simcall_rdv_get_head(smx_rdv_t rdv);
+XBT_PUBLIC(smx_process_t) simcall_rdv_get_receiver(smx_rdv_t rdv);
+XBT_PUBLIC(void) simcall_rdv_set_receiver(smx_rdv_t rdv , smx_process_t process);
XBT_PUBLIC(xbt_dict_t) SIMIX_get_rdv_points(void);
int (*match_fun)(void *, void *, smx_action_t),
void *data);
-XBT_PUBLIC(void) simcall_comm_destroy(smx_action_t comm);
+XBT_PUBLIC(void) simcall_comm_recv_bounded(smx_rdv_t rdv, void *dst_buff,
+ size_t * dst_buff_size,
+ int (*match_fun)(void *, void *, smx_action_t),
+ void *data, double timeout, double rate);
+XBT_PUBLIC(smx_action_t) simcall_comm_irecv_bounded(smx_rdv_t rdv, void *dst_buff,
+ size_t * dst_buff_size,
+ int (*match_fun)(void *, void *, smx_action_t),
+ void *data, double rate);
+
+XBT_PUBLIC(void) simcall_comm_destroy(smx_action_t comm);
+XBT_PUBLIC(smx_action_t) simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
+ int (*match_fun)(void *, void *, smx_action_t), void *data);
XBT_PUBLIC(void) simcall_comm_cancel(smx_action_t comm);
/* FIXME: waitany is going to be a vararg function, and should take a timeout */
XBT_PUBLIC(smx_sem_t) simcall_sem_init(int capacity);
XBT_PUBLIC(void) simcall_sem_destroy(smx_sem_t sem);
XBT_PUBLIC(void) simcall_sem_release(smx_sem_t sem);
-XBT_PUBLIC(void) simcall_sem_release_forever(smx_sem_t sem);
XBT_PUBLIC(int) simcall_sem_would_block(smx_sem_t sem);
-XBT_PUBLIC(void) simcall_sem_block_onto(smx_sem_t sem);
XBT_PUBLIC(void) simcall_sem_acquire(smx_sem_t sem);
XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem,
- double max_duration);
-XBT_PUBLIC(unsigned int) simcall_sem_acquire_any(xbt_dynar_t sems);
+ double max_duration);
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, 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, smx_file_t fd, s_file_stat_t *buf);
+XBT_PUBLIC(size_t) simcall_file_read(void* ptr, size_t size, smx_file_t fd);
+XBT_PUBLIC(size_t) simcall_file_write(const void* ptr, size_t size,
+ smx_file_t fd);
+XBT_PUBLIC(smx_file_t) simcall_file_open(const char* storage, const char* path);
+XBT_PUBLIC(int) simcall_file_close(smx_file_t fd);
+XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd);
+XBT_PUBLIC(xbt_dict_t) simcall_file_ls(const char* mount, const char* path);
+XBT_PUBLIC(size_t) simcall_file_get_size(smx_file_t fd);
+
+/************************** AS router **********************************/
+XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
+/************************** AS router simcalls ***************************/
+XBT_PUBLIC(xbt_dict_t) simcall_asr_get_properties(const char *name);
+
+/************************** MC simcalls **********************************/
+XBT_PUBLIC(void *) simcall_mc_snapshot(void);
+XBT_PUBLIC(int) simcall_mc_compare_snapshots(void *s1, void *s2);
+XBT_PUBLIC(int) simcall_mc_random(void);
+
+/************************** New API simcalls **********************************/
+/* TUTORIAL: New API */
+/******************************************************************************/
+XBT_PUBLIC(int) simcall_new_api_fct(const char* param1, double param2);
SG_END_DECL()
#endif /* _SIMIX_SIMIX_H */