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