Logo AND Algorithmique Numérique Distribuée

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