Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change variable waiting_task to waiting_action on msg process control.
[simgrid.git] / src / msg / private.h
1 /*     $Id$      */
2
3 /* Copyright (c) 2002-2007 Arnaud Legrand.                                  */
4 /* Copyright (c) 2007 Bruno Donassolo.                                      */
5 /* All rights reserved.                                                     */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10 #ifndef METASIMGRID_PRIVATE_H
11 #define METASIMGRID_PRIVATE_H
12
13 #include <stdio.h>
14 #include "msg/msg.h"
15 #include "simix/simix.h"
16 #include "surf/surf.h"
17 #include "xbt/fifo.h"
18 #include "xbt/dynar.h"
19 #include "xbt/swag.h"
20 #include "xbt/dict.h"
21 #include "xbt/config.h"
22
23 SG_BEGIN_DECL()
24
25 /**************** datatypes **********************************/
26 /* this structure represents a mailbox */
27      typedef struct s_msg_mailbox {
28        char *alias;             /* the key of the mailbox in the global dictionary                      */
29        xbt_fifo_t tasks;        /* the list of the tasks in the mailbox                                         */
30        smx_cond_t cond;         /* the condition on the mailbox                                                         */
31        char *hostname;          /* the name of the host containing the mailbox                          */
32      } s_msg_mailbox_t;
33
34      typedef struct simdata_host {
35        smx_host_t smx_host;     /* SURF modeling                                                                */
36        struct s_msg_mailbox **mailboxes;        /* mailboxes to store msg tasks of of the host  */
37        smx_mutex_t mutex;       /* mutex to access the host                                     */
38      } s_simdata_host_t;
39
40 /********************************* Task **************************************/
41
42      typedef struct simdata_task {
43        smx_action_t compute;    /* SURF modeling of computation  */
44        smx_action_t comm;       /* SURF modeling of communication  */
45        double message_size;     /* Data size  */
46        double computation_amount;       /* Computation size  */
47        smx_cond_t cond;
48        smx_mutex_t mutex;       /* Task mutex */
49        m_process_t sender;
50        m_process_t receiver;
51        m_host_t source;
52        double priority;
53        double rate;
54        int refcount;
55   /*******  Parallel Tasks Only !!!! *******/
56        int host_nb;
57        smx_host_t *host_list;
58        double *comp_amount;
59        double *comm_amount;
60      } s_simdata_task_t;
61
62 /******************************* Process *************************************/
63
64      typedef struct simdata_process {
65        m_host_t m_host;         /* the host on which the process is running */
66        smx_process_t s_process;
67        int PID;                 /* used for debugging purposes */
68        int PPID;                /* The parent PID */
69        m_host_t put_host;       /* used for debugging purposes */
70        m_channel_t put_channel; /* used for debugging purposes */
71        smx_action_t waiting_action;
72        int argc;                /* arguments number if any */
73        char **argv;             /* arguments table if any */
74        MSG_error_t last_errno;  /* the last value returned by a MSG_function */
75      } s_simdata_process_t;
76
77      typedef struct process_arg {
78        const char *name;
79        xbt_main_func_t code;
80        void *data;
81        m_host_t m_host;
82        int argc;
83        char **argv;
84        double kill_time;
85      } s_process_arg_t, *process_arg_t;
86
87 /************************** Global variables ********************************/
88      typedef struct MSG_Global {
89        xbt_fifo_t host;
90        xbt_fifo_t process_list;
91        int max_channel;
92        int PID;
93        int session;
94        unsigned long int sent_msg;      /* Total amount of messages sent during the simulation */
95      } s_MSG_Global_t, *MSG_Global_t;
96
97 /*extern MSG_Global_t msg_global;*/
98 XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
99
100
101 /*************************************************************/
102
103 #define PROCESS_SET_ERRNO(val) (MSG_process_self()->simdata->last_errno=val)
104 #define PROCESS_GET_ERRNO() (MSG_process_self()->simdata->last_errno)
105 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
106 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
107
108 #define CHECK_HOST()  xbt_assert1(SIMIX_host_get_state(SIMIX_host_self())==1,\
109                                   "Host failed, you cannot call this function. (state=%d)",SIMIX_host_get_state(SIMIX_host_self()))
110
111      m_host_t __MSG_host_create(smx_host_t workstation, void *data);
112
113      void __MSG_host_destroy(m_host_t host);
114
115      void __MSG_display_process_status(void);
116
117      void __MSG_process_cleanup(void *arg);
118      void *_MSG_process_create_from_SIMIX(const char *name,
119                                           xbt_main_func_t code, void *data,
120                                           char *hostname, int argc,
121                                           char **argv, xbt_dict_t properties);
122      void _MSG_process_kill_from_SIMIX(void *p);
123
124      void _MSG_action_init(void);
125
126 SG_END_DECL()
127 #endif