Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
67fa10f91b8016b7dc27c7abfb6583ef3045f3c1
[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 enum {
22   HOST_DOWN = 0,
23   HOST_ALIVE = 1
24 } m_host_state_t;
25
26 typedef struct sim_data_host {
27   void *host;                   /* SURF modeling */
28   xbt_fifo_t *mbox;             /* array of FIFOs used as a mailboxes  */
29   m_process_t *sleeping;        /* array of process used to know whether a local process is
30                                    waiting for a communication on a channel */
31   m_host_state_t state;
32   s_xbt_swag_t process_list;
33 } s_sim_data_host_t;
34
35 /********************************* Task **************************************/
36
37 typedef struct sim_data_task {
38   surf_action_t compute;        /* SURF modeling of computation  */
39   surf_action_t comm;           /* SURF modeling of communication  */
40   double message_size;          /* Data size  */
41   double computation_amount;    /* Computation size  */
42   xbt_dynar_t sleeping;         /* process to wake-up */
43 } s_sim_data_task_t;
44
45 /******************************* Process *************************************/
46
47 typedef struct sim_data_process {
48   s_xbt_swag_hookup_t host_hookup; /* link to other process running on the same location */
49   m_host_t host;                /* the host on which the process is running */
50   xbt_context_t context;                /* the context that executes the scheduler fonction */
51   int PID;                      /* used for debugging purposes */
52   int PPID;                     /* The parent PID */
53   m_task_t waiting_task;        /* used for debugging purposes */
54   m_host_t put_host;            /* used for debugging purposes */
55   int put_channel;              /* used for debugging purposes */
56   int argc;                     /* arguments number if any */
57   char **argv;                  /* arguments table if any */
58   MSG_error_t last_errno;       /* the last value returned by a MSG_function */
59 } s_sim_data_process_t;
60
61 /************************** Global variables ********************************/
62 typedef struct MSG_Global {
63   xbt_fifo_t host;
64   xbt_fifo_t link;
65   xbt_fifo_t process_to_run;
66   xbt_fifo_t process;
67   int max_channel;
68   m_process_t current_process;
69   xbt_dict_t registered_functions;
70 } s_MSG_global_t, *MSG_Global_t;
71
72 extern MSG_Global_t msg_global;
73
74 /*************************************************************/
75
76 #define PROCESS_SET_ERRNO(val) (((sim_data_process_t)(MSG_process_self()->simdata))->last_errno=val)
77 #define PROCESS_GET_ERRNO() (((sim_data_process_t)(MSG_process_self()->simdata))->last_errno)
78 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
79 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
80
81 #define CHECK_HOST()  ASSERT((((sim_data_host_t) MSG_host_self()->simdata)->state==HOST_ALIVE),"Host failed, you cannot call this function.")
82
83 m_host_t __MSG_host_create(const char *name, void *workstation,
84                            void *data);
85 void __MSG_host_destroy(m_host_t host);
86 MSG_error_t __MSG_task_wait_event(m_process_t process, m_task_t task);
87
88 #endif