Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill the types xbt_context_function_t, smx_process_code_t and m_process_code_t; use...
[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         void* (*create_process_function) ();
42         void* (*kill_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 s_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 } s_smx_simdata_process_t;
59
60 typedef struct s_smx_process_arg {
61   const char *name;
62   xbt_main_func_t code;
63   void *data;
64   char *hostname;
65   int argc;
66   char **argv;
67   double kill_time;
68 } s_smx_process_arg_t, *smx_process_arg_t;
69
70 /********************************* Mutex and Conditional ****************************/
71
72 typedef struct s_smx_mutex {
73
74    /* KEEP IT IN SYNC WITH src/xbt_sg_thread.c::struct s_xbt_mutex */
75    xbt_swag_t sleeping;                 /* list of sleeping process */
76    int using;
77    /* KEEP IT IN SYNC WITH src/xbt_sg_thread.c::struct s_xbt_mutex */
78
79 } s_smx_mutex_t;
80
81 typedef struct s_smx_cond {
82    
83    /* KEEP IT IN SYNC WITH src/xbt_sg_thread.c::struct s_xbt_cond */
84    xbt_swag_t sleeping;                         /* list of sleeping process */
85    smx_mutex_t  mutex;
86    xbt_fifo_t actions;                  /* list of actions */
87    /* KEEP IT IN SYNC WITH src/xbt_sg_thread.c::struct s_xbt_cond */
88
89 } s_smx_cond_t;
90
91 /********************************* Action **************************************/
92
93 typedef struct s_smx_simdata_action {
94   surf_action_t surf_action;    /* SURF modeling of computation  */
95   
96   smx_host_t source; 
97
98 } s_smx_simdata_action_t;
99
100
101
102 /******************************* Configuration support **********************************/
103
104 void simix_config_init(void); /* create the config set, call this before use! */
105 void simix_config_finalize(void); /* destroy the config set, call this at cleanup. */
106 extern int _simix_init_status; /* 0: beginning of time; 
107                                 1: pre-inited (cfg_set created); 
108                                 2: inited (running) */
109 extern xbt_cfg_t _simix_cfg_set;
110
111
112 #define SIMIX_CHECK_HOST()  xbt_assert0(surf_workstation_resource->extension_public-> \
113                                   get_state(SIMIX_host_self()->simdata->host)==SURF_CPU_ON,\
114                                   "Host failed, you cannot call this function.")
115
116 smx_host_t __SIMIX_host_create(const char *name, void *workstation, void *data);
117 void __SIMIX_host_destroy(smx_host_t host);
118
119 void __SIMIX_cond_wait(smx_cond_t cond);
120
121 #endif