Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
63cadc5c35430e4301fea9df9c51d9fe174a1e2a
[simgrid.git] / src / simix / private.h
1 /*      $Id$     */
2
3 /* Copyright (c) 2002,2004,2004 Arnaud Legrand. All rights reserved.        */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #ifndef SIMIX_PRIVATE_H
9 #define SIMIX_PRIVATE_H
10
11 #include "simix/simix.h"
12 #include "surf/surf.h"
13 #include "xbt/fifo.h"
14 #include "xbt/dynar.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 typedef struct s_simdata_host {
23   void *host;                   /* SURF modeling */
24   xbt_swag_t process_list;
25 } s_simdata_host_t;
26
27 /********************************* Simix Global ******************************/
28
29 typedef struct SIMIX_Global {
30   xbt_fifo_t host;
31   xbt_swag_t process_to_run;
32   xbt_swag_t process_list;
33  /* xbt_swag_t process_sleeping; */
34
35   smx_process_t current_process;
36   xbt_dict_t registered_functions;
37 /*  FILE *paje_output;
38   int session; */
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_host_t put_host;          /* used for debugging purposes */
51   int argc;                     /* arguments number if any */
52   char **argv;                  /* arguments table if any */
53   SIMIX_error_t last_errno;       /* the last value returned by a MSG_function */
54 // int paje_state;               /* the number of states stacked with Paje */
55 } s_simdata_process_t;
56
57 typedef struct process_arg {
58   const char *name;
59   smx_process_code_t code;
60   void *data;
61   smx_host_t host;
62   int argc;
63   char **argv;
64   double kill_time;
65 } s_process_arg_t, *process_arg_t;
66
67 /********************************* Mutex and Conditional ****************************/
68
69 typedef struct s_smx_mutex {
70         xbt_swag_t sleeping;
71         int using;
72
73 } s_smx_mutex_t;
74
75 typedef struct s_smx_cond {
76         s_smx_mutex_t * mutex;
77         xbt_swag_t sleeping; //process
78 } s_smx_cond_t;
79
80 /********************************* Action **************************************/
81
82 typedef struct s_simdata_action {
83   surf_action_t surf_action;    /* SURF modeling of computation  */
84   
85   xbt_fifo_t cond_list;         /* conditional variables that must be signaled when the action finish. */
86   smx_host_t source;
87
88   double priority;
89   double rate;
90   
91   /*int using;*/
92
93   /*******  Parallel Tasks Only !!!! *******/
94   /*
95   int host_nb;
96   void * *host_list;            *//* SURF modeling */
97   /*
98   double *comp_amount;
99   double *comm_amount;
100   */
101 } s_simdata_action_t;
102
103
104
105 /******************************* Configuration support **********************************/
106
107 void simix_config_init(void); /* create the config set, call this before use! */
108 void simix_config_finalize(void); /* destroy the config set, call this at cleanup. */
109 extern int _simix_init_status; /* 0: beginning of time; 
110                                 1: pre-inited (cfg_set created); 
111                                 2: inited (running) */
112 extern xbt_cfg_t _simix_cfg_set;
113
114
115
116
117
118
119 #define PROCESS_SET_ERRNO(val) (SIMIX_process_self()->simdata->last_errno=val)
120 #define PROCESS_GET_ERRNO() (SIMIX_process_self()->simdata->last_errno)
121 #define SIMIX_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
122 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
123
124 #define CHECK_HOST()  xbt_assert0(surf_workstation_resource->extension_public-> \
125                                   get_state(MSG_host_self()->simdata->host)==SURF_CPU_ON,\
126                                   "Host failed, you cannot call this function.")
127
128 smx_host_t __SIMIX_host_create(const char *name, void *workstation, void *data);
129 void __SIMIX_host_destroy(smx_host_t host);
130
131 int __SIMIX_process_block(double max_duration, const char *info);
132 SIMIX_error_t __SIMIX_process_unblock(smx_process_t process);
133 int __SIMIX_process_isBlocked(smx_process_t process);
134
135 void __SIMIX_display_process_status(void);
136
137 /*
138 void __MSG_task_execute(smx_process_t process, m_task_t task);
139 MSG_error_t __MSG_wait_for_computation(smx_process_t process, m_task_t task);
140 MSG_error_t __MSG_task_wait_event(smx_process_t process, m_task_t task);
141 */
142
143
144 #endif