Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
avoid any name clashes with msg/private.h so that the java interface can do crude...
[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
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_fifo_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         void* (*create_process_function) ();
41         void* (*kill_process_function)();
42 } s_SIMIX_Global_t, *SIMIX_Global_t;
43
44 extern SIMIX_Global_t simix_global;
45
46 /******************************* Process *************************************/
47
48 typedef struct s_smx_simdata_process {
49   smx_host_t host;                /* the host on which the process is running */
50   xbt_context_t context;                /* the context that executes the scheduler fonction */
51   int blocked;
52   int suspended;
53   smx_mutex_t mutex;            /* mutex on which the process is blocked  */
54   smx_cond_t cond;              /* cond on which the process is blocked  */
55   int argc;                     /* arguments number if any */
56   char **argv;                  /* arguments table if any */
57 } s_smx_simdata_process_t;
58
59 typedef struct s_smx_process_arg {
60   const char *name;
61   smx_process_code_t code;
62   void *data;
63   char *hostname;
64   int argc;
65   char **argv;
66   double kill_time;
67 } s_smx_process_arg_t, *smx_process_arg_t;
68
69 /********************************* Mutex and Conditional ****************************/
70
71 typedef struct s_smx_mutex {
72         xbt_swag_t sleeping;                    /* list of sleeping process */
73         int using;
74
75 } s_smx_mutex_t;
76
77 typedef struct s_smx_cond {
78         xbt_swag_t sleeping;                    /* list of sleeping process */
79         smx_mutex_t  mutex;
80         xbt_fifo_t actions;                     /* list of actions */
81
82 } s_smx_cond_t;
83
84 /********************************* Action **************************************/
85
86 typedef struct s_smx_simdata_action {
87   surf_action_t surf_action;    /* SURF modeling of computation  */
88   
89   smx_host_t source; 
90
91 } s_smx_simdata_action_t;
92
93
94
95 /******************************* Configuration support **********************************/
96
97 void simix_config_init(void); /* create the config set, call this before use! */
98 void simix_config_finalize(void); /* destroy the config set, call this at cleanup. */
99 extern int _simix_init_status; /* 0: beginning of time; 
100                                 1: pre-inited (cfg_set created); 
101                                 2: inited (running) */
102 extern xbt_cfg_t _simix_cfg_set;
103
104
105 #define SIMIX_CHECK_HOST()  xbt_assert0(surf_workstation_resource->extension_public-> \
106                                   get_state(SIMIX_host_self()->simdata->host)==SURF_CPU_ON,\
107                                   "Host failed, you cannot call this function.")
108
109 smx_host_t __SIMIX_host_create(const char *name, void *workstation, void *data);
110 void __SIMIX_host_destroy(smx_host_t host);
111
112 void __SIMIX_cond_wait(smx_cond_t cond);
113
114 void __SIMIX_display_process_status(void);
115
116
117
118 #endif