Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Do connect all log channel manually to parent using XBT_LOG_CONNECT() too, so that...
[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 /**************** datatypes **********************************/
25
26 /* this structure represents a mailbox */
27 typedef struct s_msg_mailbox
28 {
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 {
37         smx_host_t smx_host;                            /* SURF modeling                                                                */
38         struct s_msg_mailbox** mailboxes;       /* mailboxes to store msg tasks of of the host  */
39         smx_mutex_t mutex;                                      /* mutex to access the host                                     */
40 }s_simdata_host_t;
41
42 /********************************* Task **************************************/
43
44 typedef struct simdata_task {
45   smx_action_t compute; /* SURF modeling of computation  */
46   smx_action_t comm;            /* SURF modeling of communication  */
47   double message_size;          /* Data size  */
48   double computation_amount;    /* Computation size  */
49         smx_cond_t cond;                                        
50         smx_mutex_t mutex;                              /* Task mutex */
51   m_process_t sender;
52   m_process_t receiver;
53   m_host_t source;
54   double priority;
55   double rate;
56   int using;
57   /*******  Parallel Tasks Only !!!! *******/
58   int host_nb;
59   smx_host_t *host_list;
60   double *comp_amount;
61   double *comm_amount;
62 } s_simdata_task_t;
63
64 /******************************* Process *************************************/
65
66 typedef struct simdata_process {
67   m_host_t m_host;              /* the host on which the process is running */
68   smx_process_t s_process;
69   int PID;                      /* used for debugging purposes */
70   int PPID;                     /* The parent PID */
71   m_host_t put_host;            /* used for debugging purposes */
72   m_channel_t put_channel;      /* used for debugging purposes */
73   m_task_t waiting_task;
74   int argc;                     /* arguments number if any */
75   char **argv;                  /* arguments table if any */
76   MSG_error_t last_errno;       /* the last value returned by a MSG_function */
77 } s_simdata_process_t;
78
79 typedef struct process_arg {
80   const char *name;
81   xbt_main_func_t code;
82   void *data;
83   m_host_t m_host;
84   int argc;
85   char **argv;
86   double kill_time;
87 } s_process_arg_t, *process_arg_t;
88
89 /************************** Global variables ********************************/
90 typedef struct MSG_Global {
91   xbt_fifo_t host;
92   xbt_fifo_t process_list;
93   int max_channel;
94   int PID;
95   int session;
96 } s_MSG_Global_t, *MSG_Global_t;
97
98 extern MSG_Global_t msg_global;
99       
100 /*************************************************************/
101
102 #define PROCESS_SET_ERRNO(val) (MSG_process_self()->simdata->last_errno=val)
103 #define PROCESS_GET_ERRNO() (MSG_process_self()->simdata->last_errno)
104 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
105 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
106
107 #define CHECK_HOST()  xbt_assert1(SIMIX_host_get_state(SIMIX_host_self())==1,\
108                                   "Host failed, you cannot call this function. (state=%d)",SIMIX_host_get_state(SIMIX_host_self()))
109
110 m_host_t __MSG_host_create(smx_host_t workstation, void *data);
111
112 void __MSG_host_destroy(m_host_t host);
113
114 void __MSG_display_process_status(void);
115
116 void __MSG_process_cleanup(void *arg);
117 void *_MSG_process_create_from_SIMIX(const char *name,
118                                      xbt_main_func_t code, void *data,
119                                      char * hostname, int argc, char **argv, xbt_dict_t properties);
120 void _MSG_process_kill_from_SIMIX(void *p);
121
122
123 #endif