Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
630a5b0045f659c4c3f7a96367f6c150453e4cd3
[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_simdata_host {
26   void *host;                   /* SURF modeling */
27   xbt_swag_t process_list;
28 } s_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_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_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_simdata_action {
84   surf_action_t surf_action;    /* SURF modeling of computation  */
85   
86   xbt_fifo_t cond_list;         /* conditional variables that must be signaled when the action finish. */
87   smx_host_t source; 
88
89 } s_simdata_action_t;
90
91
92
93 /******************************* Configuration support **********************************/
94
95 void simix_config_init(void); /* create the config set, call this before use! */
96 void simix_config_finalize(void); /* destroy the config set, call this at cleanup. */
97 extern int _simix_init_status; /* 0: beginning of time; 
98                                 1: pre-inited (cfg_set created); 
99                                 2: inited (running) */
100 extern xbt_cfg_t _simix_cfg_set;
101
102
103 #define CHECK_HOST()  xbt_assert0(surf_workstation_resource->extension_public-> \
104                                   get_state(SIMIX_host_self()->simdata->host)==SURF_CPU_ON,\
105                                   "Host failed, you cannot call this function.")
106
107 smx_host_t __SIMIX_host_create(const char *name, void *workstation, void *data);
108 void __SIMIX_host_destroy(smx_host_t host);
109
110 void __SIMIX_cond_wait(smx_cond_t cond);
111
112 void __SIMIX_display_process_status(void);
113
114
115 #endif