Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add MSG_file_rename function
[simgrid.git] / include / simgrid / simix.h
index cdb0a2a..b595bf6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2007-2010, 2012-2013. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
 #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"
 
 SG_BEGIN_DECL()
 
@@ -34,7 +34,8 @@ typedef union u_smx_scalar u_smx_scalar_t;
 
     \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,
@@ -68,8 +69,12 @@ typedef struct s_smx_cond *smx_cond_t;
 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;
+
+/********************************** Storage *************************************/
+typedef xbt_dictelm_t smx_storage_t;
+typedef struct s_smx_storage_priv *smx_storage_priv_t;
 
 /********************************** Action *************************************/
 typedef struct s_smx_action *smx_action_t; /* FIXME: replace by specialized action handlers */
@@ -166,12 +171,6 @@ extern char* smx_context_factory_name;
 extern int smx_context_stack_size;
 extern int smx_context_stack_size_was_set;
 
-#ifdef HAVE_THREAD_LOCAL_STORAGE
-extern __thread smx_context_t smx_current_context;
-#else
-extern smx_context_t smx_current_context;
-#endif
-
 /* *********************** */
 /* Context type definition */
 /* *********************** */
@@ -265,7 +264,7 @@ 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);
-
+XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_storage_list(smx_host_t host);
 /********************************* Process ************************************/
 XBT_PUBLIC(int) SIMIX_process_count(void);
 XBT_PUBLIC(smx_process_t) SIMIX_process_self(void);
@@ -282,13 +281,16 @@ XBT_PUBLIC(void) SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_t fun,
 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);
 XBT_PUBLIC(int) SIMIX_comm_has_recv_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
 XBT_PUBLIC(void) SIMIX_comm_finish(smx_action_t action);
 
+/*********************************** File *************************************/
+XBT_PUBLIC(void*) SIMIX_file_get_data(smx_file_t fd);
+XBT_PUBLIC(void) SIMIX_file_set_data(smx_file_t fd, void *data);
+
 /******************************************************************************/
 /*                            SIMIX simcalls                                  */
 /******************************************************************************/
@@ -298,10 +300,11 @@ XBT_PUBLIC(void) SIMIX_comm_finish(smx_action_t action);
 
 /******************************* 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(int) simcall_host_get_core(smx_host_t host);
+XBT_PUBLIC(xbt_swag_t) simcall_host_get_process_list(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 */
@@ -310,6 +313,12 @@ XBT_PUBLIC(void *) simcall_host_get_data(smx_host_t host);
 
 XBT_PUBLIC(void) simcall_host_set_data(smx_host_t host, void *data);
 
+XBT_PUBLIC(double) simcall_host_get_current_power_peak(smx_host_t host);
+XBT_PUBLIC(double) simcall_host_get_power_peak_at(smx_host_t host, int pstate_index);
+XBT_PUBLIC(int) simcall_host_get_nb_pstates(smx_host_t host);
+XBT_PUBLIC(void) simcall_host_set_power_peak_at(smx_host_t host, int pstate_index);
+XBT_PUBLIC(double) simcall_host_get_consumed_energy(smx_host_t host);
+
 XBT_PUBLIC(smx_action_t) simcall_host_execute(const char *name, smx_host_t host,
                                                 double computation_amount,
                                                 double priority);
@@ -326,7 +335,7 @@ 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(e_smx_state_t) simcall_host_execution_wait(smx_action_t execution);
-
+XBT_PUBLIC(xbt_dict_t) simcall_host_get_storage_list(smx_host_t host);
 
 /**************************** Process simcalls ********************************/
 /* Constructor and Destructor */
@@ -341,7 +350,7 @@ XBT_PUBLIC(void) simcall_process_create(smx_process_t *process,
                                           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);
@@ -356,6 +365,8 @@ XBT_PUBLIC(void *) simcall_process_get_data(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);
@@ -403,6 +414,16 @@ XBT_PUBLIC(smx_action_t) simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff,
                                               int (*match_fun)(void *, void *, smx_action_t),
                                               void *data);
 
+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);
@@ -451,23 +472,34 @@ XBT_PUBLIC(void) simcall_cond_broadcast(smx_cond_t cond);
 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(double) 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* storage, const char* path, const char* mode);
-XBT_PUBLIC(int) simcall_file_close(smx_file_t fp);
-XBT_PUBLIC(int) simcall_file_stat(smx_file_t fd, s_file_stat_t *buf);
+/*****************************   File   **********************************/
+XBT_PUBLIC(void *) simcall_file_get_data(smx_file_t fd);
+XBT_PUBLIC(void) simcall_file_set_data(smx_file_t fd, void *data);
+XBT_PUBLIC(sg_storage_size_t) simcall_file_read(smx_file_t fd, sg_storage_size_t size);
+XBT_PUBLIC(sg_storage_size_t) simcall_file_write(smx_file_t fd, sg_storage_size_t size);
+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(sg_storage_size_t) simcall_file_get_size(smx_file_t fd);
+XBT_PUBLIC(xbt_dynar_t) simcall_file_get_info(smx_file_t fd);
+XBT_PUBLIC(void) simcall_file_rename(smx_file_t fd, const char* new_name);
+/*****************************   Storage   **********************************/
+XBT_PUBLIC(sg_storage_size_t) simcall_storage_get_free_size (const char* name);
+XBT_PUBLIC(sg_storage_size_t) simcall_storage_get_used_size (const char* name);
+XBT_PUBLIC(xbt_dict_t) simcall_storage_get_properties(smx_storage_t storage);
+XBT_PUBLIC(void*) SIMIX_storage_get_data(smx_storage_t storage);
+XBT_PUBLIC(void) SIMIX_storage_set_data(smx_storage_t storage, void *data);
+XBT_PUBLIC(xbt_dict_t) SIMIX_storage_get_content(smx_storage_t storage);
+XBT_PUBLIC(xbt_dict_t) simcall_storage_get_content(smx_storage_t storage);
+XBT_PUBLIC(const char*) SIMIX_storage_get_name(smx_host_t host);
+XBT_PUBLIC(sg_storage_size_t) SIMIX_storage_get_size(smx_storage_t storage);
 /************************** AS router   **********************************/
 XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
 /************************** AS router simcalls ***************************/
@@ -476,6 +508,7 @@ 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(int min, int max);
 
 /************************** New API simcalls **********************************/
 /* TUTORIAL: New API                                                          */