Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New functions added, changes in the header files, function create_link(cond, action...
[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 "simix/simix.h"
13 #include "surf/surf.h"
14 #include "xbt/fifo.h"
15 #include "xbt/dynar.h"
16 #include "xbt/swag.h"
17 #include "xbt/dict.h"
18 #include "xbt/context.h"
19 #include "xbt/config.h"
20
21 /******************************* Datatypes **********************************/
22
23
24 /********************************** Host ************************************/
25
26 typedef struct s_simdata_host {
27   void *host;                   /* SURF modeling */
28   xbt_swag_t process_list;
29 } s_simdata_host_t;
30
31 /********************************* Simix Global ******************************/
32
33 typedef struct SIMIX_Global {
34   xbt_fifo_t host;
35   xbt_swag_t process_to_run;
36   xbt_swag_t process_list;
37  /* xbt_swag_t process_sleeping; */
38
39   smx_process_t current_process;
40   xbt_dict_t registered_functions;
41 /*  FILE *paje_output;
42   int session; */
43 } s_SIMIX_Global_t, *SIMIX_Global_t;
44
45 extern SIMIX_Global_t simix_global;
46
47 /******************************* Process *************************************/
48
49 typedef struct s_simdata_process {
50   smx_host_t host;                /* the host on which the process is running */
51   xbt_context_t context;                /* the context that executes the scheduler fonction */
52   int blocked;
53   int suspended;
54   smx_mutex_t mutex;            /* mutex on which the process is blocked  */
55   smx_cond_t cond;              /* cond on which the process is blocked  */
56   smx_host_t put_host;          /* used for debugging purposes */
57   smx_action_t block_action;    /* action that block the process when it does a mutex_lock or cond_wait */
58   int argc;                     /* arguments number if any */
59   char **argv;                  /* arguments table if any */
60   SIMIX_error_t last_errno;       /* the last value returned by a MSG_function */
61 // int paje_state;               /* the number of states stacked with Paje */
62 } s_simdata_process_t;
63
64 typedef struct process_arg {
65   const char *name;
66   smx_process_code_t code;
67   void *data;
68   smx_host_t host;
69   int argc;
70   char **argv;
71   double kill_time;
72 } s_process_arg_t, *process_arg_t;
73
74 /********************************* Mutex and Conditional ****************************/
75
76 typedef struct s_smx_mutex {
77         xbt_swag_t sleeping;                    /* list of sleeping process */
78         int using;
79
80 } s_smx_mutex_t;
81
82 typedef struct s_smx_cond {
83         xbt_swag_t sleeping;                    /* list of sleeping process */
84         smx_mutex_t  mutex;
85         xbt_fifo_t actions;                     /* list of actions */
86
87 } s_smx_cond_t;
88
89 /********************************* Action **************************************/
90
91 typedef struct s_simdata_action {
92   surf_action_t surf_action;    /* SURF modeling of computation  */
93   
94   xbt_fifo_t cond_list;         /* conditional variables that must be signaled when the action finish. */
95   smx_host_t source;
96 /*
97   double priority;
98   double rate;
99 */  
100   /*int using;*/
101
102   /*******  Parallel Tasks Only !!!! *******/
103   /*
104   int host_nb;
105   void * *host_list;            *//* SURF modeling */
106   /*
107   double *comp_amount;
108   double *comm_amount;
109   */
110 } s_simdata_action_t;
111
112
113
114 /******************************* Configuration support **********************************/
115
116 void simix_config_init(void); /* create the config set, call this before use! */
117 void simix_config_finalize(void); /* destroy the config set, call this at cleanup. */
118 extern int _simix_init_status; /* 0: beginning of time; 
119                                 1: pre-inited (cfg_set created); 
120                                 2: inited (running) */
121 extern xbt_cfg_t _simix_cfg_set;
122
123
124
125
126
127
128 #define PROCESS_SET_ERRNO(val) (SIMIX_process_self()->simdata->last_errno=val)
129 #define PROCESS_GET_ERRNO() (SIMIX_process_self()->simdata->last_errno)
130 #define SIMIX_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
131 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
132
133 #define CHECK_HOST()  xbt_assert0(surf_workstation_resource->extension_public-> \
134                                   get_state(SIMIX_host_self()->simdata->host)==SURF_CPU_ON,\
135                                   "Host failed, you cannot call this function.")
136
137 smx_host_t __SIMIX_host_create(const char *name, void *workstation, void *data);
138 void __SIMIX_host_destroy(smx_host_t host);
139
140 int __SIMIX_process_block(double max_duration);
141 SIMIX_error_t __SIMIX_process_unblock(smx_process_t process);
142 int __SIMIX_process_isBlocked(smx_process_t process);
143
144 void __SIMIX_display_process_status(void);
145
146 SIMIX_error_t __SIMIX_wait_for_action(smx_process_t process, smx_action_t action);
147
148
149 /*
150 void __MSG_task_execute(smx_process_t process, m_task_t task);
151 MSG_error_t __MSG_task_wait_event(smx_process_t process, m_task_t task);
152 */
153
154
155 #endif