Logo AND Algorithmique Numérique Distribuée

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