Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Indent include and src using this command:
[simgrid.git] / src / msg / private.h
1 /* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef METASIMGRID_PRIVATE_H
8 #define METASIMGRID_PRIVATE_H
9
10 #include "msg/msg.h"
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/config.h"
18 #include "instr/private.h"
19
20 SG_BEGIN_DECL()
21
22 /**************** datatypes **********************************/
23 /* this structure represents a mailbox */
24 typedef struct s_msg_mailbox {
25   char *alias;                  /* the key of the mailbox in the global dictionary */
26   smx_cond_t cond;              /* the condition on the mailbox */
27   smx_rdv_t rdv;                /* SIMIX rendez-vous point */
28 } s_msg_mailbox_t;
29
30 typedef struct simdata_host {
31   smx_host_t smx_host;          /* SURF modeling                                                                */
32   struct s_msg_mailbox **mailboxes;     /* mailboxes to store msg tasks of of the host  */
33   smx_mutex_t mutex;            /* mutex to access the host                                     */
34 } s_simdata_host_t;
35
36 /********************************* Task **************************************/
37
38 typedef struct simdata_task {
39   smx_action_t compute;         /* SURF modeling of computation  */
40   smx_comm_t comm;              /* SIMIX communication  */
41   double message_size;          /* Data size  */
42   double computation_amount;    /* Computation size  */
43   smx_cond_t cond;
44   smx_mutex_t mutex;            /* Task mutex */
45   m_process_t sender;
46   m_process_t receiver;
47   m_host_t source;
48   double priority;
49   double rate;
50   int refcount;
51   int host_nb;                  /* ==0 if sequential task; parallel task if not */
52   /*******  Parallel Tasks Only !!!! *******/
53   smx_host_t *host_list;
54   double *comp_amount;
55   double *comm_amount;
56 } s_simdata_task_t;
57
58 /******************************* Process *************************************/
59
60 typedef struct simdata_process {
61   m_host_t m_host;              /* the host on which the process is running */
62   smx_process_t s_process;
63   int PID;                      /* used for debugging purposes */
64   int PPID;                     /* The parent PID */
65   m_host_t put_host;            /* used for debugging purposes */
66   m_channel_t put_channel;      /* used for debugging purposes */
67   smx_action_t waiting_action;
68   m_task_t waiting_task;
69   int argc;                     /* arguments number if any */
70   char **argv;                  /* arguments table if any */
71   MSG_error_t last_errno;       /* the last value returned by a MSG_function */
72 } s_simdata_process_t;
73
74 typedef struct process_arg {
75   const char *name;
76   xbt_main_func_t code;
77   void *data;
78   m_host_t m_host;
79   int argc;
80   char **argv;
81   double kill_time;
82 } s_process_arg_t, *process_arg_t;
83
84 /************************** Global variables ********************************/
85 typedef struct MSG_Global {
86   xbt_fifo_t host;
87   xbt_fifo_t process_list;
88   int max_channel;
89   int PID;
90   int session;
91   unsigned long int sent_msg;   /* Total amount of messages sent during the simulation */
92 } s_MSG_Global_t, *MSG_Global_t;
93
94 /*extern MSG_Global_t msg_global;*/
95 XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
96
97
98 /*************************************************************/
99
100 #define PROCESS_SET_ERRNO(val) (MSG_process_self()->simdata->last_errno=val)
101 #define PROCESS_GET_ERRNO() (MSG_process_self()->simdata->last_errno)
102 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
103 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
104
105 #define CHECK_HOST()  xbt_assert1(SIMIX_host_get_state(SIMIX_host_self())==1,\
106                                   "Host failed, you cannot call this function. (state=%d)",SIMIX_host_get_state(SIMIX_host_self()))
107
108 m_host_t __MSG_host_create(smx_host_t workstation, void *data);
109
110 void __MSG_host_destroy(m_host_t host);
111
112 void __MSG_display_process_status(void);
113
114 void __MSG_process_cleanup(void *arg);
115 void *_MSG_process_create_from_SIMIX(const char *name,
116                                      xbt_main_func_t code, void *data,
117                                      char *hostname, int argc,
118                                      char **argv, xbt_dict_t properties);
119 void _MSG_process_kill_from_SIMIX(void *p);
120
121 void _MSG_action_init(void);
122 void _MSG_action_exit(void);
123
124 SG_END_DECL()
125 #endif