Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ccb9e34a0cdc6ea0d15eddbb6b5f52daa9d9c150
[simgrid.git] / src / msg / private.h
1 /**** MSG_LICENCE DO NOT REMOVE ****/
2
3 #ifndef METASIMGRID_PRIVATE_H
4 #define METASIMGRID_PRIVATE_H
5
6 #include "msg/msg.h"
7 #include "surf/surf.h"
8 #include "xbt/fifo.h"
9 #include "xbt/dynar.h"
10 #include "xbt/swag.h"
11 #include "xbt/dict.h"
12 #include "xbt/context.h"
13
14 /**************** datatypes **********************************/
15
16 typedef enum {
17   HOST_DOWN = 0,
18   HOST_ALIVE = 1
19 } m_host_state_t;
20
21 typedef struct sim_data_host {
22   void *host;                   /* SURF modeling */
23   xbt_fifo_t *mbox;             /* array of FIFOs used as a mailboxes  */
24   xbt_context_t *sleeping;      /* array of context used to know whether a process is
25                                    waiting for a communication on a channel */
26   m_host_state_t state;
27   s_xbt_swag_t process_list;
28 } s_sim_data_host_t;
29
30 /********************************* Task **************************************/
31
32 typedef struct sim_data_task {
33   surf_action_t compute;        /* SURF modeling of computation  */
34   surf_action_t comm;           /* SURF modeling of communication  */
35   double message_size;          /* Data size  */
36   double computation_amount;    /* Computation size  */
37   xbt_dynar_t sleeping;         /* process to wake-up */
38 } s_sim_data_task_t;
39
40 /******************************* Process *************************************/
41
42 typedef struct sim_data_process {
43   s_xbt_swag_hookup_t host_hookup; /* link to other process running on the same location */
44   m_host_t host;                /* the host on which the process is running */
45   xbt_context_t context;                /* the context that executes the scheduler fonction */
46   int PID;                      /* used for debugging purposes */
47   int PPID;                     /* The parent PID */
48   m_task_t waiting_task;        /* used for debugging purposes */
49   m_host_t put_host;            /* used for debugging purposes */
50   int put_channel;              /* used for debugging purposes */
51   int argc;                     /* arguments number if any */
52   char **argv;                  /* arguments table if any */
53   MSG_error_t last_errno;       /* the last value returned by a MSG_function */
54 } s_sim_data_process_t;
55
56 /************************** Global variables ********************************/
57 typedef struct MSG_Global {
58   xbt_fifo_t host;
59   xbt_fifo_t link;
60   xbt_fifo_t process_to_run;
61   xbt_fifo_t process;
62   int max_channel;
63   m_process_t current_process;
64   xbt_dict_t registered_functions;
65 } s_MSG_global_t, *MSG_Global_t;
66
67 extern MSG_Global_t msg_global;
68
69 /*************************************************************/
70
71 #define PROCESS_SET_ERRNO(val) (((sim_data_process_t)(MSG_process_self()->simdata))->last_errno=val)
72 #define PROCESS_GET_ERRNO() (((sim_data_process_t)(MSG_process_self()->simdata))->last_errno)
73 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
74 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
75
76 #define CHECK_HOST()  ASSERT((((sim_data_host_t) MSG_host_self()->simdata)->state==HOST_ALIVE),"Host failed, you cannot call this function.")
77
78 m_task_t __MSG_task_copy(m_task_t task);
79 MSG_error_t __MSG_task_wait_event(m_process_t process, m_task_t task);
80
81 MSG_error_t __MSG_task_check(m_task_t task);
82
83
84 #endif