Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Sanitize the way surf options are declared: in surf_config not dupplicated in simix...
[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/function_types.h"
20
21 /******************************* Datatypes **********************************/
22
23
24 /********************************** Host ************************************/
25
26 typedef struct s_smx_simdata_host {
27   void *host;                   /* SURF modeling */
28   xbt_swag_t process_list;
29 } s_smx_simdata_host_t;
30
31 /********************************* Simix Global ******************************/
32
33 typedef struct SIMIX_Global {
34   xbt_dict_t host;
35   xbt_swag_t process_to_run;
36   xbt_swag_t process_list;
37
38   smx_process_t current_process;
39   xbt_dict_t registered_functions;
40   smx_creation_func_t create_process_function;
41   void_f_pvoid_t kill_process_function;
42   void_f_pvoid_t cleanup_process_function;
43 } s_SIMIX_Global_t, *SIMIX_Global_t;
44
45 extern SIMIX_Global_t simix_global;
46
47 /******************************* Process *************************************/
48
49 typedef struct s_smx_simdata_process {
50   smx_host_t smx_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   int argc;                     /* arguments number if any */
57   char **argv;                  /* arguments table if any */
58   xbt_dict_t properties;
59 } s_smx_simdata_process_t;
60
61 typedef struct s_smx_process_arg {
62   const char *name;
63   xbt_main_func_t code;
64   void *data;
65   char *hostname;
66   int argc;
67   char **argv;
68   double kill_time;
69   xbt_dict_t properties;
70 } s_smx_process_arg_t, *smx_process_arg_t;
71
72 /********************************* Mutex and Conditional ****************************/
73
74 typedef struct s_smx_mutex {
75
76   /* KEEP IT IN SYNC WITH src/xbt_sg_thread.c::struct s_xbt_mutex */
77   xbt_swag_t sleeping;          /* list of sleeping process */
78   int refcount;
79   /* KEEP IT IN SYNC WITH src/xbt_sg_thread.c::struct s_xbt_mutex */
80
81 } s_smx_mutex_t;
82
83 typedef struct s_smx_cond {
84
85   /* KEEP IT IN SYNC WITH src/xbt_sg_thread.c::struct s_xbt_cond */
86   xbt_swag_t sleeping;          /* list of sleeping process */
87   smx_mutex_t mutex;
88   xbt_fifo_t actions;           /* list of actions */
89   /* KEEP IT IN SYNC WITH src/xbt_sg_thread.c::struct s_xbt_cond */
90
91 } s_smx_cond_t;
92
93 /********************************* Action **************************************/
94
95 typedef struct s_smx_simdata_action {
96   surf_action_t surf_action;    /* SURF modeling of computation  */
97
98   smx_host_t source;
99
100 } s_smx_simdata_action_t;
101
102
103
104 /******************************* Other **********************************/
105
106
107 #define SIMIX_CHECK_HOST()  xbt_assert0(surf_workstation_model->extension_public-> \
108                                   get_state(SIMIX_host_self()->simdata->host)==SURF_CPU_ON,\
109                                   "Host failed, you cannot call this function.")
110
111 smx_host_t __SIMIX_host_create(const char *name, void *workstation,
112                                void *data);
113 void __SIMIX_host_destroy(void *host);
114
115 void __SIMIX_cond_wait(smx_cond_t cond);
116
117 void __SIMIX_cond_display_actions(smx_cond_t cond);
118 void __SIMIX_action_display_conditions(smx_action_t action);
119
120 #endif