Logo AND Algorithmique Numérique Distribuée

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