Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics : s/sim_data/simdata/g
[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 simdata_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   xbt_fifo_t process_list;
33 } s_simdata_host_t;
34
35 /********************************* Task **************************************/
36
37 typedef struct simdata_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_simdata_task_t;
44
45 /******************************* Process *************************************/
46
47 typedef struct simdata_process {
48   m_host_t host;                /* the host on which the process is running */
49   xbt_context_t context;                /* the context that executes the scheduler fonction */
50   int PID;                      /* used for debugging purposes */
51   int PPID;                     /* The parent PID */
52   m_task_t waiting_task;        /* used for debugging purposes */
53   m_host_t put_host;            /* used for debugging purposes */
54   int put_channel;              /* used for debugging purposes */
55   int argc;                     /* arguments number if any */
56   char **argv;                  /* arguments table if any */
57   MSG_error_t last_errno;       /* the last value returned by a MSG_function */
58 } s_simdata_process_t;
59
60 /************************** Global variables ********************************/
61 typedef struct MSG_Global {
62   xbt_fifo_t host;
63   xbt_fifo_t link;
64   xbt_fifo_t process_to_run;
65   xbt_fifo_t process;
66   int max_channel;
67   m_process_t current_process;
68   xbt_dict_t registered_functions;
69 } s_MSG_global_t, *MSG_Global_t;
70
71 extern MSG_Global_t msg_global;
72
73 /*************************************************************/
74
75 #define PROCESS_SET_ERRNO(val) (((simdata_process_t)(MSG_process_self()->simdata))->last_errno=val)
76 #define PROCESS_GET_ERRNO() (((simdata_process_t)(MSG_process_self()->simdata))->last_errno)
77 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
78 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
79
80 #define CHECK_HOST()  ASSERT((((simdata_host_t) MSG_host_self()->simdata)->state==HOST_ALIVE),"Host failed, you cannot call this function.")
81
82 m_host_t __MSG_host_create(const char *name, void *workstation,
83                            void *data);
84 void __MSG_host_destroy(m_host_t host);
85 MSG_error_t __MSG_task_wait_event(m_process_t process, m_task_t task);
86
87 #endif