Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
0b119fb842ef7ecc38f0bf214f2f44b334919873
[simgrid.git] / src / simix / private.h
1 /*      $Id$     */
2
3 /* Copyright (c) 2007 Arnaud Legrand, Bruno Donnassolo.
4    All rights reserved.                                          */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #ifndef SIMIX_PRIVATE_H
10 #define SIMIX_PRIVATE_H
11
12 #include <stdio.h>
13 #include "simix/simix.h"
14 #include "surf/surf.h"
15 #include "xbt/fifo.h"
16 #include "xbt/swag.h"
17 #include "xbt/dict.h"
18 #include "xbt/context.h"
19 #include "xbt/config.h"
20 #include "xbt/function_types.h"
21
22 /******************************* Datatypes **********************************/
23
24
25 /********************************** Host ************************************/
26
27 typedef struct s_smx_simdata_host {
28   void *host;                   /* SURF modeling */
29   xbt_swag_t process_list;
30 } s_smx_simdata_host_t;
31
32 /********************************* Simix Global ******************************/
33
34 typedef struct SIMIX_Global {
35   xbt_fifo_t host;
36   xbt_swag_t process_to_run;
37   xbt_swag_t process_list;
38
39   smx_process_t current_process;
40   xbt_dict_t registered_functions;
41   smx_creation_func_t create_process_function;
42   void_f_pvoid_t kill_process_function;
43   void_f_pvoid_t cleanup_process_function;
44 } s_SIMIX_Global_t, *SIMIX_Global_t;
45
46 extern SIMIX_Global_t simix_global;
47
48 /******************************* Process *************************************/
49
50 typedef struct s_smx_simdata_process {
51   smx_host_t smx_host;          /* the host on which the process is running */
52   xbt_context_t context;        /* the context that executes the scheduler fonction */
53   int blocked;
54   int suspended;
55   smx_mutex_t mutex;            /* mutex on which the process is blocked  */
56   smx_cond_t cond;              /* cond on which the process is blocked  */
57   int argc;                     /* arguments number if any */
58   char **argv;                  /* arguments table if any */
59   xbt_dict_t properties;
60 } s_smx_simdata_process_t;
61
62 typedef struct s_smx_process_arg {
63   const char *name;
64   xbt_main_func_t code;
65   void *data;
66   char *hostname;
67   int argc;
68   char **argv;
69   double kill_time;
70   xbt_dict_t properties;
71 } s_smx_process_arg_t, *smx_process_arg_t;
72
73 /********************************* Mutex and Conditional ****************************/
74
75 typedef struct s_smx_mutex {
76
77   /* KEEP IT IN SYNC WITH src/xbt_sg_thread.c::struct s_xbt_mutex */
78   xbt_swag_t sleeping;          /* list of sleeping process */
79   int using;
80   /* KEEP IT IN SYNC WITH src/xbt_sg_thread.c::struct s_xbt_mutex */
81
82 } s_smx_mutex_t;
83
84 typedef struct s_smx_cond {
85
86   /* KEEP IT IN SYNC WITH src/xbt_sg_thread.c::struct s_xbt_cond */
87   xbt_swag_t sleeping;          /* list of sleeping process */
88   smx_mutex_t mutex;
89   xbt_fifo_t actions;           /* list of actions */
90   /* KEEP IT IN SYNC WITH src/xbt_sg_thread.c::struct s_xbt_cond */
91
92 } s_smx_cond_t;
93
94 /********************************* Action **************************************/
95
96 typedef struct s_smx_simdata_action {
97   surf_action_t surf_action;    /* SURF modeling of computation  */
98
99   smx_host_t source;
100
101 } s_smx_simdata_action_t;
102
103
104
105 /******************************* Configuration support **********************************/
106
107 void simix_config_init(void);   /* create the config set, call this before use! */
108 void simix_config_finalize(void);       /* destroy the config set, call this at cleanup. */
109 extern int _simix_init_status;  /* 0: beginning of time; 
110                                    1: pre-inited (cfg_set created); 
111                                    2: inited (running) */
112 extern xbt_cfg_t _simix_cfg_set;
113
114
115 #define SIMIX_CHECK_HOST()  xbt_assert0(surf_workstation_model->extension_public-> \
116                                   get_state(SIMIX_host_self()->simdata->host)==SURF_CPU_ON,\
117                                   "Host failed, you cannot call this function.")
118
119 smx_host_t __SIMIX_host_create(const char *name, void *workstation,
120                                void *data);
121 void __SIMIX_host_destroy(smx_host_t host);
122
123 void __SIMIX_cond_wait(smx_cond_t cond);
124
125 void __SIMIX_cond_display_actions(smx_cond_t cond);
126 void __SIMIX_action_display_conditions(smx_action_t action);
127
128 xbt_dict_t current_property_set;
129
130 #endif