Logo AND Algorithmique Numérique Distribuée

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