Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
dbc1a6414cbf8f17e1c05174504fac52a1fb4595
[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 process used to know whether a local process is
27                                    waiting for a communication on a channel */
28         smx_mutex_t mutex;
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;
40   m_process_t sender;
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_task_t waiting_task;        
60   int blocked;
61   int suspended;
62   m_host_t put_host;            /* used for debugging purposes */
63   m_channel_t put_channel;      /* used for debugging purposes */
64   int argc;                     /* arguments number if any */
65   char **argv;                  /* arguments table if any */
66   MSG_error_t last_errno;       /* the last value returned by a MSG_function */
67 } s_simdata_process_t;
68
69 typedef struct process_arg {
70   const char *name;
71   m_process_code_t code;
72   void *data;
73   m_host_t host;
74   int argc;
75   char **argv;
76   double kill_time;
77 } s_process_arg_t, *process_arg_t;
78
79 /************************** Global variables ********************************/
80 typedef struct MSG_Global {
81   xbt_fifo_t host;
82   xbt_fifo_t process_list;
83   int max_channel;
84   int PID;
85   int session;
86 } s_MSG_Global_t, *MSG_Global_t;
87
88 extern MSG_Global_t msg_global;
89       
90 /*************************************************************/
91
92 #define PROCESS_SET_ERRNO(val) (MSG_process_self()->simdata->last_errno=val)
93 #define PROCESS_GET_ERRNO() (MSG_process_self()->simdata->last_errno)
94 //#define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
95 #define MSG_RETURN(val) do {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 void __MSG_host_destroy(m_host_t host);
103 void __MSG_task_execute(m_process_t process, m_task_t task);
104 MSG_error_t __MSG_wait_for_computation(m_process_t process, m_task_t task);
105 MSG_error_t __MSG_task_wait_event(m_process_t process, m_task_t task);
106
107 int __MSG_process_block(double max_duration, const char *info);
108 MSG_error_t __MSG_process_unblock(m_process_t process);
109 int __MSG_process_isBlocked(m_process_t process);
110
111 void __MSG_display_process_status(void);
112
113 m_process_t __MSG_process_create_with_arguments(const char *name,
114                                               m_process_code_t code, void *data,
115                                                                                                               char * hostname, int argc, char **argv);
116
117
118 #endif