Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Necessity to change the code to implement MSG..
[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/swag.h"
16 #include "xbt/dict.h"
17 #include "xbt/context.h"
18 #include "xbt/config.h"
19
20 /******************************* Datatypes **********************************/
21
22
23 /********************************** Host ************************************/
24
25 typedef struct s_smx_simdata_host {
26   void *host;                   /* SURF modeling */
27   xbt_swag_t process_list;
28 } s_smx_simdata_host_t;
29
30 /********************************* Simix Global ******************************/
31
32 typedef struct SIMIX_Global {
33   xbt_fifo_t host;
34   xbt_swag_t process_to_run;
35   xbt_swag_t process_list;
36
37   smx_process_t current_process;
38   xbt_dict_t registered_functions;
39 } s_SIMIX_Global_t, *SIMIX_Global_t;
40
41 extern SIMIX_Global_t simix_global;
42
43 /******************************* Process *************************************/
44
45 typedef struct s_smx_simdata_process {
46   smx_host_t host;                /* the host on which the process is running */
47   xbt_context_t context;                /* the context that executes the scheduler fonction */
48   int blocked;
49   int suspended;
50   smx_mutex_t mutex;            /* mutex on which the process is blocked  */
51   smx_cond_t cond;              /* cond on which the process is blocked  */
52   int argc;                     /* arguments number if any */
53   char **argv;                  /* arguments table if any */
54 } s_smx_simdata_process_t;
55
56 typedef struct process_arg {
57   const char *name;
58   smx_process_code_t code;
59   void *data;
60   smx_host_t host;
61   int argc;
62   char **argv;
63   double kill_time;
64 } s_process_arg_t, *process_arg_t;
65
66 /********************************* Mutex and Conditional ****************************/
67
68 typedef struct s_smx_mutex {
69         xbt_swag_t sleeping;                    /* list of sleeping process */
70         int using;
71
72 } s_smx_mutex_t;
73
74 typedef struct s_smx_cond {
75         xbt_swag_t sleeping;                    /* list of sleeping process */
76         smx_mutex_t  mutex;
77         xbt_fifo_t actions;                     /* list of actions */
78
79 } s_smx_cond_t;
80
81 /********************************* Action **************************************/
82
83 typedef struct s_smx_simdata_action {
84   surf_action_t surf_action;    /* SURF modeling of computation  */
85   
86   smx_host_t source; 
87
88 } s_smx_simdata_action_t;
89
90
91
92 /******************************* Configuration support **********************************/
93
94 void simix_config_init(void); /* create the config set, call this before use! */
95 void simix_config_finalize(void); /* destroy the config set, call this at cleanup. */
96 extern int _simix_init_status; /* 0: beginning of time; 
97                                 1: pre-inited (cfg_set created); 
98                                 2: inited (running) */
99 extern xbt_cfg_t _simix_cfg_set;
100
101
102 #define CHECK_HOST()  xbt_assert0(surf_workstation_resource->extension_public-> \
103                                   get_state(SIMIX_host_self()->simdata->host)==SURF_CPU_ON,\
104                                   "Host failed, you cannot call this function.")
105
106 smx_host_t __SIMIX_host_create(const char *name, void *workstation, void *data);
107 void __SIMIX_host_destroy(smx_host_t host);
108
109 void __SIMIX_cond_wait(smx_cond_t cond);
110
111 void __SIMIX_display_process_status(void);
112
113
114 #endif