3 /* Copyright (c) 2002-2007 Arnaud Legrand. */
4 /* Copyright (c) 2007 Bruno Donassolo. */
5 /* All rights reserved. */
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. */
10 #ifndef METASIMGRID_PRIVATE_H
11 #define METASIMGRID_PRIVATE_H
14 #include "simix/simix.h"
15 #include "surf/surf.h"
17 #include "xbt/dynar.h"
20 #include "xbt/config.h"
24 /**************** datatypes **********************************/
25 /* this structure represents a mailbox */
26 typedef struct s_msg_mailbox {
27 char *alias; /* the key of the mailbox in the global dictionary */
28 smx_cond_t cond; /* the condition on the mailbox */
29 smx_rdv_t rdv; /* SIMIX rendez-vous point */
32 typedef struct simdata_host {
33 smx_host_t smx_host; /* SURF modeling */
34 struct s_msg_mailbox **mailboxes; /* mailboxes to store msg tasks of of the host */
35 smx_mutex_t mutex; /* mutex to access the host */
38 /********************************* Task **************************************/
40 typedef struct simdata_task {
41 smx_action_t compute; /* SURF modeling of computation */
42 smx_comm_t comm; /* SIMIX communication */
43 double message_size; /* Data size */
44 double computation_amount; /* Computation size */
46 smx_mutex_t mutex; /* Task mutex */
53 /******* Parallel Tasks Only !!!! *******/
55 smx_host_t *host_list;
60 /******************************* Process *************************************/
62 typedef struct simdata_process {
63 m_host_t m_host; /* the host on which the process is running */
64 smx_process_t s_process;
65 int PID; /* used for debugging purposes */
66 int PPID; /* The parent PID */
67 m_host_t put_host; /* used for debugging purposes */
68 m_channel_t put_channel; /* used for debugging purposes */
69 smx_action_t waiting_action;
70 m_task_t waiting_task;
71 int argc; /* arguments number if any */
72 char **argv; /* arguments table if any */
73 MSG_error_t last_errno; /* the last value returned by a MSG_function */
74 } s_simdata_process_t;
76 typedef struct process_arg {
84 } s_process_arg_t, *process_arg_t;
86 /************************** Global variables ********************************/
87 typedef struct MSG_Global {
89 xbt_fifo_t process_list;
93 unsigned long int sent_msg; /* Total amount of messages sent during the simulation */
94 } s_MSG_Global_t, *MSG_Global_t;
96 /*extern MSG_Global_t msg_global;*/
97 XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
100 /*************************************************************/
102 #define PROCESS_SET_ERRNO(val) (MSG_process_self()->simdata->last_errno=val)
103 #define PROCESS_GET_ERRNO() (MSG_process_self()->simdata->last_errno)
104 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
105 /* #define CHECK_ERRNO() ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
107 #define CHECK_HOST() xbt_assert1(SIMIX_host_get_state(SIMIX_host_self())==1,\
108 "Host failed, you cannot call this function. (state=%d)",SIMIX_host_get_state(SIMIX_host_self()))
110 m_host_t __MSG_host_create(smx_host_t workstation, void *data);
112 void __MSG_host_destroy(m_host_t host);
114 void __MSG_display_process_status(void);
116 void __MSG_process_cleanup(void *arg);
117 void *_MSG_process_create_from_SIMIX(const char *name,
118 xbt_main_func_t code, void *data,
119 char *hostname, int argc,
120 char **argv, xbt_dict_t properties);
121 void _MSG_process_kill_from_SIMIX(void *p);
123 void _MSG_action_init(void);
124 void _MSG_action_exit(void);