Logo AND Algorithmique Numérique Distribuée

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