Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Start the implementation of start_time and kill_time in the msg deployment.
[simgrid.git] / src / msg / private.h
1 /*      $Id$     */
2
3 /* Copyright (c) 2002,2004,2004 Arnaud Legrand. 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 "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/context.h"
18
19 /**************** datatypes **********************************/
20
21 typedef struct simdata_host {
22   void *host;                   /* SURF modeling */
23   xbt_fifo_t *mbox;             /* array of FIFOs used as a mailboxes  */
24   m_process_t *sleeping;        /* array of process used to know whether a local process is
25                                    waiting for a communication on a channel */
26   xbt_fifo_t process_list;
27 } s_simdata_host_t;
28
29 /********************************* Task **************************************/
30
31 typedef struct simdata_task {
32   surf_action_t compute;        /* SURF modeling of computation  */
33   surf_action_t comm;           /* SURF modeling of communication  */
34   double message_size;          /* Data size  */
35   double computation_amount;    /* Computation size  */
36   xbt_dynar_t sleeping;         /* process to wake-up */
37   m_process_t sender;
38   double rate;
39   int using;
40 } s_simdata_task_t;
41
42 /******************************* Process *************************************/
43
44 typedef struct simdata_process {
45   m_host_t host;                /* the host on which the process is running */
46   xbt_context_t context;                /* the context that executes the scheduler fonction */
47   int PID;                      /* used for debugging purposes */
48   int PPID;                     /* The parent PID */
49   m_task_t waiting_task;        
50   int blocked;
51   int suspended;
52   m_host_t put_host;            /* used for debugging purposes */
53   m_channel_t put_channel;      /* used for debugging purposes */
54   int argc;                     /* arguments number if any */
55   char **argv;                  /* arguments table if any */
56   MSG_error_t last_errno;       /* the last value returned by a MSG_function */
57   int paje_state;               /* the number of state stacked with Paje */
58   double kill_time;             /* When to kill the process */
59 } s_simdata_process_t;
60
61 /************************** Global variables ********************************/
62 typedef struct MSG_Global {
63   xbt_fifo_t host;
64   xbt_fifo_t process_to_run;
65   xbt_fifo_t process_list;
66   int max_channel;
67   m_process_t current_process;
68   xbt_dict_t registered_functions;
69   FILE *paje_output;
70   int paje_maxPID;
71   int PID;
72   int session;
73 } s_MSG_Global_t, *MSG_Global_t;
74
75 extern MSG_Global_t msg_global;
76
77 /*************************************************************/
78
79 #define PROCESS_SET_ERRNO(val) (MSG_process_self()->simdata->last_errno=val)
80 #define PROCESS_GET_ERRNO() (MSG_process_self()->simdata->last_errno)
81 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
82 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
83
84 #define CHECK_HOST()  xbt_assert0(surf_workstation_resource->extension_public-> \
85                                   get_state(MSG_host_self()->simdata->host)==SURF_CPU_ON,\
86                                   "Host failed, you cannot call this function.")
87
88 m_host_t __MSG_host_create(const char *name, void *workstation,
89                            void *data);
90 void __MSG_host_destroy(m_host_t host);
91 void __MSG_task_execute(m_process_t process, m_task_t task);
92 MSG_error_t __MSG_wait_for_computation(m_process_t process, m_task_t task);
93 MSG_error_t __MSG_task_wait_event(m_process_t process, m_task_t task);
94
95 MSG_error_t __MSG_process_block(void);
96 MSG_error_t __MSG_process_unblock(m_process_t process);
97 int __MSG_process_isBlocked(m_process_t process);
98
99 #ifdef ALVIN_SPECIAL_LOGING
100 #define PAJE_PROCESS_STATE(process,state)\
101   if(msg_global->paje_output) \
102     fprintf(msg_global->paje_output,"10 %lg S_t P%d %s\n",\
103             surf_get_clock(), (process)->simdata->PID,(state))
104 #define PAJE_PROCESS_PUSH_STATE(process,state)\
105   if(msg_global->paje_output) { \
106     fprintf(msg_global->paje_output,"11 %lg S_t P%d %s\n",\
107             surf_get_clock(), (process)->simdata->PID,(state));\
108     (process)->simdata->paje_state++; \
109   }
110 #define PAJE_PROCESS_POP_STATE(process)\
111   if(msg_global->paje_output) { \
112     fprintf(msg_global->paje_output,"12 %lg S_t P%d\n",\
113             surf_get_clock(), (process)->simdata->PID); \
114     (process)->simdata->paje_state--; \
115   }
116 #define PAJE_PROCESS_FREE(process)
117 #define PAJE_PROCESS_NEW(process)\
118   if((msg_global->paje_output)) {\
119     if((msg_global->session==0) || ((msg_global->session>0) && ((process)->simdata->PID > msg_global->paje_maxPID))) \
120     fprintf(msg_global->paje_output,"7 %lg P%d P_t %p \"%s %d (%d)\"\n", \
121             surf_get_clock(), (process)->simdata->PID, (process)->simdata->host, \
122             (process)->name, (process)->simdata->PID, msg_global->session);\
123     if(msg_global->paje_maxPID<(process)->simdata->PID) msg_global->paje_maxPID=(process)->simdata->PID;\
124     }
125 #define PAJE_COMM_START(process,task,channel)\
126   if(msg_global->paje_output) \
127     fprintf(msg_global->paje_output,\
128             "16 %lg     Comm    CUR     COMM_%d P%d     %p\n", \
129             surf_get_clock(), channel, (process)->simdata->PID, task)
130 #define PAJE_COMM_STOP(process,task,channel)\
131   if(msg_global->paje_output) \
132     fprintf(msg_global->paje_output,\
133             "17 %lg     Comm    CUR     COMM_%d P%d     %p\n", \
134             surf_get_clock(), channel, (process)->simdata->PID, task)
135 #define PAJE_HOST_NEW(host)\
136   if(msg_global->paje_output)\
137     fprintf(msg_global->paje_output,"7 %lg %p H_t CUR \"%s\"\n",surf_get_clock(), \
138             host, host->name)
139 #define PAJE_HOST_FREE(host)\
140   if(msg_global->paje_output)\
141     fprintf(msg_global->paje_output,"8 %lg %p H_t\n",surf_get_clock(), host)
142
143 #else
144
145 #define PAJE_PROCESS_STATE(process,state)\
146   if(msg_global->paje_output) \
147     fprintf(msg_global->paje_output,"10 %lg S_t %p %s\n",\
148             surf_get_clock(), (process),(state))
149 #define PAJE_PROCESS_PUSH_STATE(process,state)\
150   if(msg_global->paje_output) \
151     fprintf(msg_global->paje_output,"11 %lg S_t %p %s\n",\
152             surf_get_clock(), (process),(state))
153 #define PAJE_PROCESS_POP_STATE(process)\
154   if(msg_global->paje_output) \
155     fprintf(msg_global->paje_output,"12 %lg S_t %p\n",\
156             surf_get_clock(), (process))
157
158 #define PAJE_PROCESS_FREE(process)\
159   if(msg_global->paje_output) \
160     fprintf(msg_global->paje_output,"8 %lg %p P_t\n", \
161             surf_get_clock(), (process))
162 #define PAJE_PROCESS_NEW(process)\
163   if(msg_global->paje_output) \
164     fprintf(msg_global->paje_output,"7 %lg %p P_t %p \"%s %d (%d)\"\n", \
165             surf_get_clock(), (process), (process)->simdata->host, \
166             (process)->name, (process)->simdata->PID, msg_global->session)
167 #define PAJE_COMM_START(process,task,channel)\
168   if(msg_global->paje_output) \
169     fprintf(msg_global->paje_output,\
170             "16 %lg     Comm    CUR     COMM_%d %p      %p\n", \
171             surf_get_clock(), channel, (process), task)
172 #define PAJE_COMM_STOP(process,task,channel)\
173   if(msg_global->paje_output) \
174     fprintf(msg_global->paje_output,\
175             "17 %lg     Comm    CUR     COMM_%d %p      %p\n", \
176             surf_get_clock(), channel, (process), task)
177 #define PAJE_HOST_NEW(host)\
178   if(msg_global->paje_output)\
179     fprintf(msg_global->paje_output,"7 %lg %p H_t CUR \"%s\"\n",surf_get_clock(), \
180             host, host->name)
181 #define PAJE_HOST_FREE(host)\
182   if(msg_global->paje_output)\
183     fprintf(msg_global->paje_output,"8 %lg %p H_t\n",surf_get_clock(), host);
184
185 #endif /* Alvin_Special_Loging */
186 #endif